├── .gitignore ├── ChangeLog.md ├── LICENSE ├── README.md ├── Setup.hs ├── cam-julia ├── Manifest.toml ├── Project.toml ├── src │ ├── CamJulia.jl │ ├── CommonAbstractMachine.jl │ ├── IdrisForeignCollections.jl │ ├── IdrisList.jl │ ├── ReadIR.jl │ └── Runtime.jl └── test │ ├── runtests.jl │ ├── test.cam │ └── text.txt ├── examples ├── a.idr ├── pair.idr └── test_ffi.idr ├── idris-cam.cabal ├── libs ├── Cam │ ├── Data │ │ ├── Collections.idr │ │ ├── Compat.idr │ │ └── FCollections.idr │ ├── FFI.idr │ ├── IO.idr │ └── OS │ │ ├── FileSystem.idr │ │ └── Platform.idr ├── Test │ └── Simple.idr ├── cam.ipkg ├── clean_ibc.py ├── gen_test.py └── test.idr ├── src ├── IRTS │ └── CodegenCam.hs └── Main.hs ├── stack.yaml ├── test └── Spec.hs └── tools └── prim-fn-gen.py /.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work/ 2 | idris-python.cabal 3 | *~ 4 | *.ibc 5 | *.o 6 | **_flymake.hs 7 | 8 | # 9 | libs/test2.idr 10 | 11 | # dot 12 | **Digraph.gv 13 | 14 | # emacs 15 | **~ 16 | **\.#* 17 | **#*# 18 | 19 | 20 | # editors 21 | .idea/ 22 | .vscode/ 23 | 24 | # Byte-compiled / optimized / DLL files 25 | __pycache__/ 26 | *.py[cod] 27 | *$py.class 28 | .coverage 29 | 30 | # C extensions 31 | *.so 32 | 33 | # Distribution / packaging 34 | .Python 35 | build/ 36 | develop-eggs/ 37 | dist/ 38 | downloads/ 39 | eggs/ 40 | .eggs/ 41 | lib/ 42 | lib64/ 43 | parts/ 44 | sdist/ 45 | var/ 46 | wheels/ 47 | *.egg-info/ 48 | .installed.cfg 49 | *.egg 50 | MANIFEST 51 | 52 | # PyInstaller 53 | # Usually these files are written by a python script from a template 54 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 55 | *.manifest 56 | *.spec 57 | 58 | # Installer logs 59 | pip-log.txt 60 | pip-delete-this-directory.txt 61 | 62 | # Unit test / coverage reports 63 | htmlcov/ 64 | .tox/ 65 | .coverage 66 | .coverage.* 67 | .cache 68 | nosetests.xml 69 | coverage.xml 70 | *.cover 71 | .hypothesis/ 72 | .pytest_cache/ 73 | 74 | # Translations 75 | *.mo 76 | *.pot 77 | 78 | # Django stuff: 79 | *.log 80 | local_settings.py 81 | db.sqlite3 82 | 83 | # Flask stuff: 84 | instance/ 85 | .webassets-cache 86 | 87 | # Scrapy stuff: 88 | .scrapy 89 | 90 | # Sphinx documentation 91 | docs/_build/ 92 | 93 | # PyBuilder 94 | target/ 95 | 96 | # Jupyter Notebook 97 | .ipynb_checkpoints 98 | 99 | # pyenv 100 | .python-version 101 | 102 | # celery beat schedule file 103 | celerybeat-schedule 104 | 105 | # SageMath parsed files 106 | *.sage.py 107 | 108 | # Environments 109 | .env 110 | .venv 111 | env/ 112 | venv/ 113 | ENV/ 114 | env.bak/ 115 | venv.bak/ 116 | 117 | # Spyder project settings 118 | .spyderproject 119 | .spyproject 120 | 121 | # Rope project settings 122 | .ropeproject 123 | 124 | # mkdocs documentation 125 | /site 126 | 127 | # mypy 128 | .mypy_cache/ 129 | 130 | 131 | stack.yaml.lock -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # Changelog for idris-python 2 | 3 | ## Unreleased changes 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright thautwarm (c) 2019 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of thautwarm nor the names of other 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # idris-cam 2 | 3 | A framework for Idris RTS. 4 | 5 | 6 | ## Features(listed by priorities) 7 | 8 | - [x] An abstraction of some intermediate representations(common abstract machine, aka CAM) 9 | - [x] Back end: Python AST 10 | - [x] Back end: Julia AST 11 | - [ ] Persisting locations with Idris IRs, like DDecls. 12 | - [ ] Python standard libraries 13 | - [x] Handy FFI 14 | - [ ] Tail call elimination 15 | - [ ] Back end: Python Bytecode 16 | - [ ] Specializations for some primitive data types 17 | - [ ] Incremental compilation 18 | 19 | ## Build && Cam Codegen 20 | 21 | - Build 22 | 23 | ``` 24 | git clone https://github.com/thautwarm/idris-cam && cd idris-cam 25 | stack build 26 | ``` 27 | 28 | - Codegen 29 | 30 | ``` 31 | stack exec idris -- --codegen=cam -o 32 | ``` 33 | 34 | - Install to `.local` 35 | 36 | ``` 37 | stack install 38 | ``` 39 | 40 | After installing this, your `idris` command could use `cam` back end via `idris --codegen cam`. 41 | 42 | - Usage within `idris` command. 43 | 44 | ``` 45 | idris f1.idr f2.idr -o out.cam --codegen cam -p cam 46 | ``` 47 | 48 | - Run `.cam` files 49 | 50 | - Idris-Python 51 | 52 | You can check [Idris-Python](https://github.com/thautwarm/idris-python), and install it 53 | via [pip](https://pypi.org/project/pip/) will give you a command `run-cam` which accepts 54 | a filename of `.cam` file and executes it in Python. 55 | 56 | Also, you can load `.cam` file in Python session, via [load_cam function](https://github.com/thautwarm/idris-python/blob/master/idris_python/cli.py#L69). 57 | 58 | - Idris-Julia 59 | 60 | Check [cam-julia/test/runtests.jl](https://github.com/thautwarm/idris-cam/blob/master/cam-julia/test/runtests.jl). 61 | 62 | It hasn't been published yet. 63 | 64 | ## Python & Julia Example 65 | 66 | 67 | ### Test Generation 68 | 69 | You can test the Idris package `Cam`, generating test files for Python or Julia with 70 | 71 | ``` 72 | ~/github/idris-cam | master> cd libs && python gen_test.py 73 | ``` 74 | 75 | Above command compiles `idris-cam/libs/Test/Simple.idr` into `.cam` file. 76 | 77 | ```idris 78 | -- idris-cam/libs/Test/Simple.idr 79 | module Test.Simple 80 | import Cam.FFI 81 | import Cam.OS.FileSystem 82 | import Cam.IO 83 | import Cam.Data.Collections 84 | import Cam.Data.FCollections 85 | import Cam.Data.Compat 86 | import Data.Vect 87 | import Data.HVect 88 | 89 | %hide HVect.index 90 | %hide Vect.index 91 | %hide Vect.reverse 92 | 93 | %access export 94 | 95 | testSimple : FFI.IO () 96 | testSimple = do 97 | -- In Julia, use "MLStyle" or other Julia module. 98 | sklearn <- camImport $ TheModule "sklearn" 99 | 100 | -- fprintln works for only foreign objects 101 | fprintln sklearn 102 | 103 | -- get property of module 104 | external_mod <- camImportFrom sklearn "externals" 105 | 106 | -- println works for all objects 107 | println external_mod 108 | 109 | file <- openFile "./text.txt" "r" 110 | text <- readAllText file 111 | closeFile file 112 | fprintln $ text 113 | println $ "test hvec: " show hvec 114 | where 115 | hvec : HVect [Double, Int] 116 | hvec = reverse [1.0, 5] 117 | ``` 118 | 119 | ### Test in Python 120 | 121 | Use `idris-python` command from [Idris-Python](https://github.com/thautwarm/idris-python). Change module name from `Test.Simple` to `Main` is okay. 122 | 123 | ``` 124 | idris-python main.idr 125 | ``` 126 | 127 | ### Test in Julia 128 | 129 | ``` 130 | ~/github/idris-cam | master> cd cam-julia 131 | ~/github/idris-cam | master> julia 132 | ~/github/idris-cam | master> cd cam-julia 133 | julia> ] 134 | v1.1> activate . 135 | (CamJulia) pkg> test 136 | Testing CamJulia 137 | Resolving package versions... 138 | 139 | MLStyle 140 | MLStyle.MatchCore.gen_match 141 | 啊,太懂了!太懂Idris Julia辣! 142 | 143 | test hvec: [1.0, 5] 144 | ``` 145 | 146 | 147 | ## Cam Loader 148 | 149 | A `.cam` file is simply a JSON file consist of the abstract instructions which could be loaded by Python and Julia and compiled conveniently. 150 | 151 | For Julia, there's a [`@load_cam` macro](https://github.com/thautwarm/idris-cam/blob/master/cam-julia/test/runtests.jl): 152 | 153 | ```julia 154 | macro load_cam(path) 155 | aeson = CamJulia.ReadIR.load_aeson(path); 156 | ir = CamJulia.ReadIR.aeson_to_ir(aeson) 157 | x = CamJulia.CAM.ir_to_julia(ir) 158 | esc(x) 159 | end 160 | 161 | @load_cam "./test.cam" 162 | ``` 163 | 164 | For Python, there is a [`load_cal` function](https://github.com/thautwarm/idris-python/blob/master/idris_python/loader.py): 165 | 166 | ```python 167 | def load_cam(path, session): 168 | with open(path, 'r') as f: 169 | js = json.load(f) 170 | 171 | letrec: LetRec = aeson_to_ir(js) 172 | return run_code(letrec, session) 173 | ``` 174 | 175 | The `session` argument of Python's `load_cam` indicates a symbol generator. Comparisons of symbols are O(1) thus allow us to 176 | create efficient tagged unions(ADTs, data types). In Julia, `Symbol` is an essential type. 177 | 178 | ## FFI Mechansim 179 | 180 | 181 | Our handy FFI becomes feasible due to [New Foreign Function Interface](http://docs.idris-lang.org/en/latest/reference/ffi.html). 182 | 183 | ### Idris Side 184 | 185 | In Idris side, we have made a FFI implementation for Idris-CAM, and then you can 186 | declare foreign functions via such codes: 187 | 188 | ```idris 189 | println : Unsafe -> FFI.IO Unsafe 190 | println s = fcall (Unsafe -> FFI.IO Unsafe) (Builtin "println") s 191 | ``` 192 | 193 | You can check [libs/Cam](https://github.com/thautwarm/idris-cam/blob/master/libs/Cam) for more information, and I'll make Idris libraries for both Julia and Python sooner. 194 | 195 | 196 | ### Target Back End 197 | 198 | We have already Julia and Python back ends, and Python's is already available, so we use Python to demonstrate how 199 | to setup FFI. 200 | 201 | Note that we referenced `println` as builtin functions in previous Idris codes. 202 | 203 | 204 | So we update [runtime.py](https://github.com/thautwarm/idris-python/blob/0c4fdb523658c521e789944a12eb235b7f67dc23/idris_python/runtime.py#L99), add its 205 | implementation: 206 | 207 | ```python 208 | return { 209 | 'cam-rt.cmp': operator.eq, 210 | 'cam-rt.is': operator.is_, 211 | ... 212 | 'builtin-println': print, 213 | ... 214 | } 215 | ``` 216 | -------------------------------------------------------------------------------- /Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /cam-julia/Manifest.toml: -------------------------------------------------------------------------------- 1 | # This file is machine-generated - editing it directly is not advised 2 | 3 | [[ArgParse]] 4 | deps = ["Compat", "Test", "TextWrap"] 5 | git-tree-sha1 = "14d5789a99e6bea3e258d668ec09359a9feaf2d1" 6 | uuid = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" 7 | version = "0.6.2" 8 | 9 | [[Base64]] 10 | uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" 11 | 12 | [[BinDeps]] 13 | deps = ["Compat", "Libdl", "SHA", "URIParser"] 14 | git-tree-sha1 = "12093ca6cdd0ee547c39b1870e0c9c3f154d9ca9" 15 | uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" 16 | version = "0.8.10" 17 | 18 | [[BinaryProvider]] 19 | deps = ["Libdl", "Pkg", "SHA", "Test"] 20 | git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" 21 | uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" 22 | version = "0.5.3" 23 | 24 | [[BufferedStreams]] 25 | deps = ["Compat", "Test"] 26 | git-tree-sha1 = "5d55b9486590fdda5905c275bb21ce1f0754020f" 27 | uuid = "e1450e63-4bb3-523b-b2a4-4ffa8c0fd77d" 28 | version = "1.0.0" 29 | 30 | [[Compat]] 31 | deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] 32 | git-tree-sha1 = "84aa74986c5b9b898b0d1acaf3258741ee64754f" 33 | uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" 34 | version = "2.1.0" 35 | 36 | [[Dates]] 37 | deps = ["Printf"] 38 | uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" 39 | 40 | [[DelimitedFiles]] 41 | deps = ["Mmap"] 42 | uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" 43 | 44 | [[Distributed]] 45 | deps = ["Random", "Serialization", "Sockets"] 46 | uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" 47 | 48 | [[HTTPClient]] 49 | deps = ["Compat", "LibCURL"] 50 | git-tree-sha1 = "161d5776ae8e585ac0b8c20fb81f17ab755b3671" 51 | uuid = "0862f596-cf2d-50af-8ef4-f2be67dfa83f" 52 | version = "0.2.1" 53 | 54 | [[InteractiveUtils]] 55 | deps = ["Markdown"] 56 | uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" 57 | 58 | [[JSON2]] 59 | deps = ["Dates", "Parsers", "Test"] 60 | git-tree-sha1 = "7e46c37f892d98a0b676e6663c828859fff89ecd" 61 | uuid = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3" 62 | version = "0.2.4" 63 | 64 | [[LibCURL]] 65 | deps = ["BinaryProvider", "Libdl", "Printf", "Test"] 66 | git-tree-sha1 = "d051c8057512ca38a273aaa514145a0b25f24d46" 67 | uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" 68 | version = "0.5.0" 69 | 70 | [[LibExpat]] 71 | deps = ["Compat"] 72 | git-tree-sha1 = "fde352ec13479e2f90e57939da2440fb78c5e388" 73 | uuid = "522f3ed2-3f36-55e3-b6df-e94fee9b0c07" 74 | version = "0.5.0" 75 | 76 | [[LibGit2]] 77 | uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" 78 | 79 | [[Libdl]] 80 | uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" 81 | 82 | [[Libz]] 83 | deps = ["BufferedStreams", "Random", "Test"] 84 | git-tree-sha1 = "d405194ffc0293c3519d4f7251ce51baac9cc871" 85 | uuid = "2ec943e9-cfe8-584d-b93d-64dcb6d567b7" 86 | version = "1.0.0" 87 | 88 | [[LinearAlgebra]] 89 | deps = ["Libdl"] 90 | uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" 91 | 92 | [[Logging]] 93 | uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" 94 | 95 | [[MLStyle]] 96 | deps = ["Statistics", "Test"] 97 | git-tree-sha1 = "12d2f421dcff9c12b2aebcc25759f0cdca16a16b" 98 | uuid = "d8e11817-5142-5d16-987a-aa16d5891078" 99 | version = "0.3.0" 100 | 101 | [[Markdown]] 102 | deps = ["Base64"] 103 | uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" 104 | 105 | [[Missings]] 106 | deps = ["Dates", "InteractiveUtils", "SparseArrays", "Test"] 107 | git-tree-sha1 = "d1d2585677f2bd93a97cfeb8faa7a0de0f982042" 108 | uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" 109 | version = "0.4.0" 110 | 111 | [[Mmap]] 112 | uuid = "a63ad114-7e13-5084-954f-fe012c677804" 113 | 114 | [[PackageCompiler]] 115 | deps = ["ArgParse", "Libdl", "Pkg", "REPL", "Serialization", "Test", "UUIDs", "WinRPM"] 116 | git-tree-sha1 = "3db96de5bc51934d50872b1122f3ebe258a5b4f2" 117 | uuid = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" 118 | version = "0.6.3" 119 | 120 | [[Parsers]] 121 | deps = ["Dates", "Mmap", "Test", "WeakRefStrings"] 122 | git-tree-sha1 = "d4e634c9cab597f0ec8f5a1d62c0787e98602c55" 123 | uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" 124 | version = "0.2.22" 125 | 126 | [[Pkg]] 127 | deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] 128 | uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" 129 | 130 | [[Printf]] 131 | deps = ["Unicode"] 132 | uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" 133 | 134 | [[REPL]] 135 | deps = ["InteractiveUtils", "Markdown", "Sockets"] 136 | uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" 137 | 138 | [[Random]] 139 | deps = ["Serialization"] 140 | uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" 141 | 142 | [[SHA]] 143 | uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" 144 | 145 | [[Serialization]] 146 | uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" 147 | 148 | [[SharedArrays]] 149 | deps = ["Distributed", "Mmap", "Random", "Serialization"] 150 | uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" 151 | 152 | [[Sockets]] 153 | uuid = "6462fe0b-24de-5631-8697-dd941f90decc" 154 | 155 | [[SparseArrays]] 156 | deps = ["LinearAlgebra", "Random"] 157 | uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" 158 | 159 | [[Statistics]] 160 | deps = ["LinearAlgebra", "SparseArrays"] 161 | uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" 162 | 163 | [[Test]] 164 | deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] 165 | uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" 166 | 167 | [[TextWrap]] 168 | deps = ["Compat", "Test"] 169 | git-tree-sha1 = "8355cc559e85469cd4dbe927c375f61d3750e002" 170 | uuid = "b718987f-49a8-5099-9789-dcd902bef87d" 171 | version = "0.3.0" 172 | 173 | [[URIParser]] 174 | deps = ["Test", "Unicode"] 175 | git-tree-sha1 = "6ddf8244220dfda2f17539fa8c9de20d6c575b69" 176 | uuid = "30578b45-9adc-5946-b283-645ec420af67" 177 | version = "0.4.0" 178 | 179 | [[UUIDs]] 180 | deps = ["Random", "SHA"] 181 | uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" 182 | 183 | [[Unicode]] 184 | uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" 185 | 186 | [[WeakRefStrings]] 187 | deps = ["Missings", "Random", "Test"] 188 | git-tree-sha1 = "960639a12ffd223ee463e93392aeb260fa325566" 189 | uuid = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" 190 | version = "0.5.8" 191 | 192 | [[WinRPM]] 193 | deps = ["BinDeps", "Compat", "HTTPClient", "LibExpat", "Libdl", "Libz", "URIParser"] 194 | git-tree-sha1 = "2a889d320f3b77d17c037f295859fe570133cfbf" 195 | uuid = "c17dfb99-b4f7-5aad-8812-456da1ad7187" 196 | version = "0.4.2" 197 | -------------------------------------------------------------------------------- /cam-julia/Project.toml: -------------------------------------------------------------------------------- 1 | name = "CamJulia" 2 | uuid = "2a781b1a-60f5-11e9-32e7-8fba6ff62213" 3 | authors = ["thautwarm "] 4 | version = "0.1.0" 5 | 6 | [deps] 7 | JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3" 8 | MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078" 9 | PackageCompiler = "9b87118b-4619-50d2-8e1e-99f35a4d4d9d" 10 | -------------------------------------------------------------------------------- /cam-julia/src/CamJulia.jl: -------------------------------------------------------------------------------- 1 | module CamJulia 2 | export IdrisList, Runtime 3 | 4 | export IdrisIntegerT 5 | IdrisIntegerT = Int64 6 | 7 | 8 | include("IdrisList.jl") 9 | include("IdrisForeignCollections.jl") 10 | include("Runtime.jl") 11 | include("CommonAbstractMachine.jl") 12 | include("ReadIR.jl") 13 | 14 | macro load_cam(path) 15 | aeson = ReadIR.load_aeson(path); 16 | ir = ReadIR.aeson_to_ir(aeson) 17 | x = CAM.ir_to_julia(ir) 18 | esc(x) 19 | end 20 | 21 | end # module 22 | -------------------------------------------------------------------------------- /cam-julia/src/CommonAbstractMachine.jl: -------------------------------------------------------------------------------- 1 | module CAM 2 | using MLStyle 3 | using MLStyle.Infras: @format, mangle 4 | using CamJulia.Runtime 5 | using CamJulia 6 | 7 | 8 | @use Enum # replace `S() => ...` with `S => ...` 9 | 10 | # held here until merged into MLStyle master. 11 | def_pattern(CAM, 12 | predicate = (@λ begin 13 | :[$_ for $_ in $_] -> true 14 | _ -> false 15 | end), 16 | rewrite = (tag, case, mod) -> begin 17 | @match case begin 18 | :[$expr for $iter in $seq] => begin 19 | function (body) 20 | iter_var = mangle(mod) 21 | produced_elt_var = mangle(mod) 22 | inner_test_var = mangle(mod) 23 | seq_var = mangle(mod) 24 | decons_elt = mk_pattern(iter_var, expr, mod)(iter) 25 | decons_seq = mk_pattern(seq_var, seq, mod)(body) 26 | @format [ 27 | seq_var, iter_var, inner_test_var, produced_elt_var, 28 | body, tag, decons_elt, decons_seq, push!] quote 29 | if tag isa Vector 30 | let seq_var = [], inner_test_var = true 31 | for iter_var in tag 32 | produced_elt_var = decons_elt 33 | if produced_elt_var === failed 34 | inner_test_var = false 35 | break 36 | end 37 | push!(seq_var, produced_elt_var) 38 | end 39 | if inner_test_var 40 | decons_seq 41 | else 42 | failed 43 | end 44 | end 45 | else 46 | failed 47 | end 48 | end 49 | end 50 | end 51 | end 52 | 53 | end 54 | ) 55 | 56 | export IR, Let, LetRec, If, While, Mutate, Fun 57 | export App, Var, Block, Join, Proj 58 | export BigIntConst, IntConst, DoubleConst 59 | export StrConst, ChConst, BoolConst, NilConst 60 | export Internal, Located, SymConst 61 | 62 | 63 | @data IR begin 64 | Let(String, IR, IR) 65 | LetRec(Vector{Tuple{String, IR}}, IR) 66 | If(IR, IR, IR) 67 | While(IR, IR) 68 | Mutate(String, IR) 69 | Fun(Vector{String}, IR) 70 | App(IR, Vector{IR}) 71 | Var(String) 72 | Block(Vector{IR}) 73 | Join(Vector{IR}) 74 | Proj(IR, IR) 75 | 76 | BigIntConst(IdrisIntegerT) 77 | IntConst(Int) 78 | DoubleConst(Float64) 79 | StrConst(String) 80 | ChConst(Char) 81 | BoolConst(Bool) 82 | SymConst(String) 83 | NilConst() 84 | 85 | Internal(String) 86 | Located(fname::Union{Nothing, String}, line::Int, column::Int, value::IR) 87 | end 88 | 89 | @active Sym(x :: String) begin 90 | Symbol(x) 91 | end 92 | 93 | @active Julia(x) begin 94 | ir_to_julia(x) 95 | end 96 | 97 | export ir_to_julia 98 | 99 | @active LetToDef(tp) begin 100 | @match tp begin 101 | (Sym(fname), Fun([Sym(arg) for arg in args], Julia(body))) => 102 | :($fname($(args...), ) = $body) 103 | end 104 | end 105 | 106 | @generated function projection(x, i :: Int) 107 | x <: Tuple ? :(x[i]) : :(if i === 1; x else throw("internal runtime error") end) 108 | end 109 | 110 | ir_to_julia(ir::IR) = 111 | @match ir begin 112 | SymConst(Sym(sym)) => QuoteNode(sym) 113 | Var(Sym(sym)) => sym 114 | # Let(Sym(fn_name), Fun([Sym(arg) for arg in args], Julia(fn_body)), Julia(body)) => 115 | # :(let $fn_name($(args...), ) = $fn_body; $body end) 116 | Let(Sym(s), Julia(value), Julia(body)) => 117 | :(let $s = $value; $body end) 118 | 119 | # letrec: bindings must be all functions 120 | LetRec([LetToDef(tp) for tp in seq], Julia(value)) => 121 | Expr(:block, seq..., value) 122 | If(Julia(cond), Julia(iftrue), Julia(iffalse)) => 123 | :(if $cond; $iftrue else $iffalse end) 124 | While(Julia(cond), Julia(body)) => 125 | :(while $cond; $body end) 126 | Mutate(Sym(s), Julia(value)) => 127 | :($s = $value) 128 | Fun([Sym(s) for s in args], Julia(body)) => 129 | :(function ($(args...), ) $body end) 130 | 131 | App(Internal("builtin-get_module"), [StrConst(c)]) => 132 | let paths = map(Symbol, split(c, ".")), 133 | imp = @match paths begin 134 | [] => throw("no module accessing path given! requires a path like `a.b.c`!") 135 | [x] => x 136 | _ => Expr(:., paths) 137 | end 138 | quote 139 | @eval import $imp 140 | $imp 141 | end 142 | end 143 | 144 | App(Julia(fn), [Julia(arg) for arg in args]) => 145 | :($fn($(args...), )) 146 | 147 | Block([Julia(expr) for expr in seq]) => 148 | :(begin $(seq...) end) 149 | Join([Julia(elt) for elt in elts]) => 150 | :($(elts...), ) 151 | Proj(Julia(major), Julia(ith)) => 152 | :($projection($major, $ith + 1)) 153 | # :($major[$ith + 1]) 154 | 155 | StrConst(c) => foldr(c, init=CamJulia.IdrisList.IdrisNil{Char}()) do each, prev 156 | each ^ prev 157 | end 158 | 159 | BigIntConst(c) || IntConst(c) || DoubleConst(c) || 160 | # TODO: str const needs to be unescaped, e.g., '\\a' -> '\a' 161 | ChConst(c) || BoolConst(c) => c 162 | 163 | NilConst => :nothing # kind of tricky for Julia use :nothing to represent nothing in ASTs 164 | 165 | Internal(s) => rt_support[s] 166 | Located(fname, lineno, _, Julia(value)) => # colno doesn't have an effect in current julia. 167 | let lineno = LineNumberNode(lineno, fname) 168 | :(begin $lineno; $value end) 169 | end 170 | a => throw(a) 171 | end 172 | end 173 | -------------------------------------------------------------------------------- /cam-julia/src/IdrisForeignCollections.jl: -------------------------------------------------------------------------------- 1 | module IdrisForeignCollections 2 | using CamJulia.IdrisList 3 | 4 | 5 | FList = IdrisList 6 | 7 | const HVECT_NIL = Symbol("Data.HVect.Nil") 8 | const HVECT_CONS = Symbol("Data.HVect.::") 9 | 10 | const VECT_NIL = Symbol("Data.Vect.Nil") 11 | const VECT_CONS = Symbol("Data.Vect.::") 12 | 13 | const LIST_NIL = Symbol("Prelude.List.Nil") 14 | const LIST_CONS = Symbol("Prelude.List.::") 15 | 16 | export from_flist, to_flist 17 | export to_flist! 18 | export map_hvect 19 | export to_fvect, from_fvect 20 | export to_fhvect, from_fhvect 21 | 22 | function from_flist(jl_lst :: Vector{T}) where T 23 | foldr(jl_lst, init=LIST_NIL) do each, prev 24 | (LIST_CONS, each, prev) 25 | end 26 | end 27 | 28 | 29 | function to_flist!(c :: Vector{T}, flist::Symbol) where T 30 | nothing 31 | end 32 | 33 | function to_flist!(c :: Vector{T}, flist::Tuple{Symbol, T, A}) where {T, A} 34 | while flist !== LIST_NIL 35 | push!(c, flist[2]) 36 | flist = flist[3] 37 | end 38 | end 39 | 40 | function to_flist(flist :: Symbol) 41 | [] 42 | end 43 | 44 | function to_flist(flist::Tuple{Symbol, T, A}) where {T, A} 45 | c = T[] 46 | to_flist!(c, flist) 47 | c 48 | end 49 | 50 | function map_hvect(f, a::Symbol) 51 | a 52 | end 53 | 54 | function map_hvect(f, a :: Tuple{Symbol, T, A}) where {T, A} 55 | (a[1], f(a[2]), map_hvect(f, a[3])) 56 | end 57 | 58 | function from_fvect(n :: Int64, vec :: Vector{T}) where T 59 | prev = VECT_NIL 60 | for i = n:-1:1 61 | prev = (VECT_CONS, vec[i], prev) 62 | end 63 | prev 64 | end 65 | 66 | function to_fvect(n :: Int64, vec :: Symbol) 67 | [] 68 | end 69 | 70 | function to_fvect(n :: Int64, vec :: Tuple{Symbol, T, A}) where {T, A} 71 | v = Vector{T}(UndefInitializer(), n) 72 | i = 1 73 | while vec[3] !== VECT_NIL 74 | v[i] = vec[2] 75 | vec = vec[3] 76 | i = i + 1 77 | end 78 | @assert vec[3] === VECT_NIL 79 | v[i] = vec[2] 80 | v 81 | end 82 | 83 | 84 | function from_fhvect(n :: Int64, vec :: Tuple) where T 85 | prev = HVECT_NIL 86 | for i = n:-1:1 87 | prev = (HVECT_CONS, vec[i], prev) 88 | end 89 | prev 90 | end 91 | 92 | function to_fhvect(n :: Int64, vec :: Symbol) 93 | () 94 | end 95 | 96 | @generated function to_fhvect(n :: Int64, vec :: Tuple{Symbol, T, A}) where {T, A} 97 | node = vec 98 | vars = [] 99 | while node <: Tuple 100 | ps = node.parameters 101 | push!(vars, gensym("elt" * string(ps[2]))) 102 | node = ps[end] 103 | end 104 | 105 | tp = gensym("tp") 106 | expr = foldr(vars, init=Expr(:tuple, vars...)) do cur_var, prev 107 | :(let $cur_var = $tp[2], $tp=$tp[3]; $prev end) 108 | end 109 | :(let $tp = vec; $expr end) 110 | end 111 | 112 | end 113 | -------------------------------------------------------------------------------- /cam-julia/src/IdrisList.jl: -------------------------------------------------------------------------------- 1 | module IdrisList 2 | import Base: (>), (<), (>=), (<=), (==), (^), foreach 3 | using MLStyle 4 | 5 | @use Enum 6 | 7 | export AbstractIdrisList, IdrisCons, IdrisNil 8 | 9 | @data AbstractIdrisList{T} begin 10 | IdrisCons(head::T, tail::AbstractIdrisList{T}) 11 | IdrisNil() 12 | end 13 | 14 | export IdrisString 15 | IdrisString = AbstractIdrisList{Char} 16 | 17 | function Base.collect(x::IdrisNil{A}) :: Vector{A} where A 18 | [] 19 | end 20 | 21 | function Base.collect(x::IdrisCons{A}) :: Vector{A} where A 22 | vec :: Vector{A} = [] 23 | foreach(x) do e 24 | push!(vec, e) 25 | end 26 | vec 27 | end 28 | 29 | Base.length(::IdrisNil{A}) where A = 0 30 | function Base.length(xs::IdrisCons{A}) where A 31 | len = 1 32 | nil = IdrisNil{A}() 33 | while xs.tail !== nil 34 | len += 1 35 | xs = xs.tail 36 | end 37 | len 38 | end 39 | 40 | Base.getindex(xs::IdrisNil{A}, i::Int) where A = 41 | throw("Cannot index empty list") 42 | 43 | function Base.getindex(xs::IdrisCons{A}, i::Int) where A 44 | nil = IdrisNil{A}() 45 | while i !== 0 46 | if xs.tail === nil 47 | throw("Cannot index empty list") 48 | end 49 | xs = xs.tail 50 | i -= 1 51 | end 52 | xs.head 53 | end 54 | 55 | 56 | function foreach(f::Function, xs::IdrisNil{A}) where A 57 | nothing 58 | end 59 | 60 | function foreach(f::Function, xs::IdrisCons{A}) where A 61 | f(xs.head) 62 | nil = IdrisNil{A}() 63 | if nil === xs.tail 64 | return 65 | end 66 | cur = xs.tail 67 | while cur.tail !== nil 68 | f(cur.head) 69 | cur = cur.tail 70 | end 71 | f(cur.head) 72 | return 73 | end 74 | 75 | Base.print(io::IO, x::IdrisNil{Char}) = Base.print(io, "") 76 | Base.print(io::IO, x::IdrisCons{Char}) = foreach(x) do c 77 | print(io, c) 78 | end 79 | 80 | Base.show(io::IO, x::IdrisNil{Char}) = Base.show("") 81 | Base.show(io::IO, x::IdrisCons{Char}) = Base.show(io, String(collect(x))) 82 | 83 | Base.show(io::IO, x::IdrisNil{T}) where T = "[]" 84 | function Base.show(io::IO, x::IdrisCons{T}) where T 85 | print(io, "[") 86 | print(io, x.head) 87 | foreach(x.tail) do each 88 | print(io, ", ") 89 | print(io, each) 90 | end 91 | print(io, "]") 92 | end 93 | 94 | export string_cons 95 | function string_cons(c::Char, s::S) where S <: IdrisString 96 | IdrisCons(c, s) 97 | end 98 | 99 | ^(c::Elt, s::S) where {Elt, S <: AbstractIdrisList{Elt}} = IdrisCons{Elt}(c, s) 100 | 101 | export from_text 102 | function from_text(s :: String) 103 | ret = IdrisNil{Char}() 104 | foreach(reverse(s)) do c 105 | ret = c ^ ret 106 | end 107 | ret 108 | end 109 | 110 | export string_head 111 | string_head(::IdrisNil{Char}) = throw("Empty String cannot extract head") 112 | string_head(xs::IdrisCons{Char}) :: Char = xs.head 113 | 114 | export string_tail 115 | string_tail(::IdrisNil{Char}) = throw("Empty String cannot extract tail") 116 | string_tail(xs::IdrisCons{Char}) = xs.tail 117 | 118 | 119 | export string_concat 120 | string_concat(xs1::IdrisNil{Char}, xs2::IdrisString) = xs2 121 | string_concat(xs1::IdrisCons{Char}, xs2::IdrisString) = 122 | IdrisCons(xs1.head, string_concat(xs1.tail, xs2)) 123 | 124 | 125 | export string_len 126 | string_len(xs::IdrisNil{Char}) = 0 127 | string_len(xs::IdrisCons{Char}) = length(xs) 128 | 129 | 130 | const EQ = Int8(0) 131 | const GT = Int8(1) 132 | const LT = Int8(-1) 133 | const PENDING = Int8(2) 134 | 135 | export list_compare 136 | function list_compare(xs1::AbstractIdrisList{A}, xs2::AbstractIdrisList{A}) where A 137 | ended = false 138 | res = PENDING 139 | while !ended 140 | ended, res = @match (xs1, xs2) begin 141 | (IdrisNil{A}, IdrisNil{A}) => (true, EQ) 142 | (IdrisNil{A}, _) => (true, LT) 143 | (_, IdrisNil{A}) => (true, GT) 144 | (IdrisCons(a1, s2), IdrisCons(a2, s2)) => 145 | a1 < a2 ? (true, LT) : a1 > a2 ? (true, GT) : (false, PENDING) 146 | end 147 | end 148 | res 149 | end 150 | 151 | >(xs1::AbstractIdrisList, xs2::AbstractIdrisList) = list_compare(xs1, xs2) === GT 152 | <(xs1::AbstractIdrisList, xs2::AbstractIdrisList) = list_compare(xs1, xs2) === LT 153 | ==(xs1::AbstractIdrisList, xs2::AbstractIdrisList) = list_compare(xs1, xs2) === EQ 154 | >=(xs1::AbstractIdrisList, xs2::AbstractIdrisList) = 155 | let cmp = list_compare(xs1, xs2) 156 | cmp === EQ || cmp === GT 157 | end 158 | <=(xs1::AbstractIdrisList, xs2::AbstractIdrisList) = 159 | let cmp = list_compare(xs1, xs2) 160 | cmp === EQ || cmp === LT 161 | end 162 | 163 | 164 | # println(1 ^ 2 ^ IdrisNil{Int}()) 165 | 166 | # println('1' ^ '2' ^ IdrisNil{Char}()) 167 | 168 | end 169 | -------------------------------------------------------------------------------- /cam-julia/src/ReadIR.jl: -------------------------------------------------------------------------------- 1 | module ReadIR 2 | using JSON2 3 | using MLStyle 4 | using CamJulia 5 | using CamJulia.CAM 6 | 7 | export load_aeson, aeson_to_ir 8 | 9 | function load_aeson(path) 10 | open(path) do f 11 | let s = read(f, String) 12 | JSON2.read(s, NamedTuple) 13 | end 14 | end 15 | end 16 | 17 | function aeson_to_ir(x::NamedTuple) 18 | f = @match x.tag begin 19 | "ComLet" => com_let 20 | "ComLetrec" => com_letrec 21 | "ComIf" => com_if 22 | "ComWhile" => com_while 23 | "ComMutate" => com_mut 24 | "ComFun" => com_fun 25 | "ComApp" => com_app 26 | "ComVar" => com_var 27 | "ComBlock" => com_block 28 | "ComTuple" => com_tuple 29 | "ComProj" => com_proj 30 | "ComSymbol" => com_sym 31 | "ComInt" => com_int 32 | "ComBigInt" => com_bigint 33 | "ComDouble" => com_double 34 | "ComCh" => com_ch 35 | "ComBool" => com_bool 36 | "ComStr" => com_str 37 | "ComNil" => nothing 38 | "ComInternal" => com_internal 39 | a => throw(a) 40 | end 41 | f === nothing ? NilConst() : f(x.contents) 42 | end 43 | 44 | @active Load(x) begin 45 | aeson_to_ir(x) 46 | end 47 | 48 | list_conv(xs) = map(aeson_to_ir, xs) 49 | 50 | 51 | com_let = @λ [name, Load(value), Load(body)] -> 52 | Let(name, value, body) 53 | 54 | com_letrec = @λ [ 55 | [[fst, Load(snd)] for (fst, snd) in bindings], 56 | Load(body) 57 | ] -> LetRec(bindings, body) 58 | 59 | com_if = @λ [Load(cond), Load(iftrue), Load(iffasle)] -> 60 | If(cond, iftrue, iffasle) 61 | 62 | com_while = @λ [Load(cond), Load(body)] -> 63 | While(cond, body) 64 | 65 | com_mut = @λ [varname, Load(value)] -> Mutate(varname, value) 66 | 67 | com_fun = @λ [args, Load(body)] -> Fun(args, body) 68 | 69 | com_app = @λ [Load(fn), [Load(arg) for arg in args]] -> App(fn, args) 70 | 71 | com_var = Var 72 | 73 | com_block = @λ [Load(expr) for expr in blocks] -> Block(blocks) 74 | 75 | com_tuple = @λ [Load(elt) for elt in elts] -> Join(elts) 76 | 77 | com_proj = @λ [Load(major), Load(ith)] -> Proj(major, ith) 78 | 79 | com_bigint = BigIntConst ∘ IdrisIntegerT 80 | 81 | com_sym = SymConst 82 | 83 | com_int = IntConst 84 | 85 | com_str = StrConst 86 | 87 | com_double = DoubleConst 88 | 89 | com_ch = @λ s -> ChConst(s[1]) 90 | 91 | com_bool = BoolConst 92 | 93 | com_internal = Internal 94 | 95 | end 96 | 97 | -------------------------------------------------------------------------------- /cam-julia/src/Runtime.jl: -------------------------------------------------------------------------------- 1 | # internal objects, placed to ASTs in compiling time 2 | module Runtime 3 | using MLStyle 4 | using CamJulia.IdrisList 5 | using CamJulia.IdrisForeignCollections 6 | 7 | struct FileHandler 8 | filename :: String 9 | mode :: String 10 | end 11 | 12 | simple_open(filename::IdrisString) = FileHandler(string(filename), "r") 13 | simple_read(f::FileHandler) = open(f.filename) do f 14 | from_text(read(f, String)) 15 | end 16 | 17 | 18 | read_all_text(f::IOStream) = read(f, String) 19 | 20 | filesystem_pipe(::Nothing) = (1, 2) 21 | 22 | @inline function is(a :: T , b :: T) where T 23 | a === b 24 | end 25 | 26 | is(_, _) = false 27 | 28 | @inline function to_list_str(s) 29 | from_text(string(s)) 30 | end 31 | 32 | @inline function parse_from_list_str(::Type{T}, s::IdrisString) where T 33 | parse(T, string(s)) 34 | end 35 | 36 | function parse_int_from_list_str(s::IdrisString) 37 | parse_from_list_str(Int, s) 38 | end 39 | 40 | function parse_double_from_list_str(s::IdrisString) 41 | parse_from_list_str(Float64, s) 42 | end 43 | 44 | @inline function module_property(m :: Module, s::String) 45 | getproperty(m, Symbol(s)) 46 | end 47 | 48 | export rt_support 49 | rt_support = Dict{String, Any}( 50 | "cam-rt.cmp" => (==), 51 | "cam-rt.err" => throw, 52 | "cam-rt.is" => is, 53 | 54 | "prim-plus" => (+), 55 | "prim-minus" => (-), 56 | "prim-times" => (*), 57 | "prim-udiv" => div, 58 | "prim-sdiv" => div, 59 | "prim-urem" => rem, 60 | "prim-srem" => rem, 61 | "prim-eq" => (==), 62 | "prim-slt" => (<), 63 | "prim-sle" => (<=), 64 | "prim-sgt" => (>), 65 | "prim-sge" => (>=), 66 | "prim-and" => (&), 67 | "prim-or" => (|), 68 | 69 | # str methods1 70 | "prim-streq" => (==), 71 | "prim-strlen" => string_len, 72 | "prim-strindex" => getindex, 73 | "prim-strlt" => (<=), 74 | 75 | # effect 76 | "prim-external" => throw, 77 | "prim-readstr" => readline, 78 | "prim-writestr" => print, 79 | 80 | # conversion 81 | "prim-floatstr" => to_list_str, 82 | "prim-strfloat" => x -> parse(Float64, x) ∘ string, 83 | "prim-intstr" => to_list_str, 84 | "prim-strint" => x -> parse(Int, x) ∘ string, 85 | "prim-intch" => Char, 86 | "prim-chint" => Int, 87 | 88 | # str method2 89 | "prim-strhead" => string_head, 90 | "prim-strtail" => string_tail, 91 | "prim-strcons" => string_cons, 92 | "prim-strconcat" => string_concat, 93 | "prim-crash" => throw, 94 | 95 | # io 96 | "builtin-println" => println, 97 | "builtin-simple_open" => simple_open, 98 | "builtin-simple_read" => simple_read, 99 | "builtin-filesystem_pipe" => filesystem_pipe, 100 | "builtin-filesystem_open_file" => open, 101 | "builtin-filesystem_close_file" => close, 102 | "builtin-filesystem_read_all_text" => read_all_text, 103 | 104 | # flist 105 | "builtin-reverse_flist" => reverse, 106 | "builtin-flist_to_native" => from_flist, 107 | "builtin-list_to_foreign" => to_flist, 108 | 109 | # fvect 110 | "builtin-reverse_fvect" => reverse, 111 | "builtin-fvect_to_native" => from_fvect, 112 | "builtin-vect_to_foreign" => to_fvect, 113 | 114 | # fhvect 115 | "builtin-reverse_fhvect" => reverse, 116 | "builtin-fhvect_to_native" => from_fhvect, 117 | "builtin-hvect_to_foreign" => to_fhvect, 118 | 119 | # string 120 | "builtin-to_text" => string, 121 | "builtin-fstr_to_native" => from_text, 122 | "builtin-str_to_foreign" => string, 123 | 124 | "builtin-map_hvect" => map_hvect, 125 | "builtin-module_property" => module_property, 126 | 127 | ) 128 | end 129 | 130 | -------------------------------------------------------------------------------- /cam-julia/test/runtests.jl: -------------------------------------------------------------------------------- 1 | using CamJulia 2 | using MLStyle 3 | 4 | rmlines = @λ begin 5 | Expr(head, args...) -> Expr(head, filter(x -> x !== nothing, map(rmlines, args))...) 6 | ::LineNumberNode -> nothing 7 | a -> a 8 | end 9 | 10 | macro load_cam(path) 11 | aeson = CamJulia.ReadIR.load_aeson(path); 12 | ir = CamJulia.ReadIR.aeson_to_ir(aeson) 13 | x = CamJulia.CAM.ir_to_julia(ir) 14 | # @info rmlines(x) 15 | esc(x) 16 | end 17 | 18 | # @load_cam "./test.cam" 19 | @load_cam "/tmp/idris19309-1" 20 | -------------------------------------------------------------------------------- /cam-julia/test/test.cam: -------------------------------------------------------------------------------- 1 | {"tag":"ComLetrec","contents":[[["ForeignEnv.::",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"ForeignEnv.::"}]}]}],["Prelude.List.::",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.List.::"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Prelude.Stream.::",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Stream.::"},{"tag":"ComVar","contents":"var.0"}]}]}],["=",{"tag":"ComFun","contents":[["var.0","var.1","var.2","var.3"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"="},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"},{"tag":"ComVar","contents":"var.3"}]}]}],["Language.Reflection.ATDouble",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ATDouble"}]}]}],["Language.Reflection.ATInt",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ATInt"}]}]}],["Language.Reflection.AType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.AType"}]}]}],["Prelude.Interfaces.Abs",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Abs"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.WellFounded.Access",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.WellFounded.Access"}]}]}],["Prelude.WellFounded.Accessible",{"tag":"ComFun","contents":[["var.0","var.1","var.2"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.WellFounded.Accessible"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"}]}]}],["Prelude.Nat.Additive",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.Additive"}]}]}],["Language.Reflection.AllTypes",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.AllTypes"}]}]}],["Language.Reflection.Errors.AlreadyDefined",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.AlreadyDefined"}]}]}],["Prelude.Applicative.Alternative",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Applicative.Alternative"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.App",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.App"}]}]}],["Prelude.Show.App",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.App"}]}]}],["Prelude.File.Append",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.Append"}]}]}],["Prelude.Applicative.Applicative",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Applicative.Applicative"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.ApplyTactic",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ApplyTactic"}]}]}],["Language.Reflection.ArithTy",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ArithTy"}]}]}],["Language.Reflection.B16",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.B16"}]}]}],["Language.Reflection.B32",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.B32"}]}]}],["Language.Reflection.B64",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.B64"}]}]}],["Language.Reflection.B8",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.B8"}]}]}],["Language.Reflection.BI",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.BI"}]}]}],["Prelude.Show.Backtick",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.Backtick"}]}]}],["Language.Reflection.Bind",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Bind"}]}]}],["Language.Reflection.Binder",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Binder"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Bool.Bool",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Bool.Bool"}]}]}],["Ownership.Borrowed",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Ownership.Borrowed"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Bound",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Bound"}]}]}],["Main.Builtin",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.Builtin"}]}]}],["Language.Reflection.ByReflection",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ByReflection"}]}]}],["CData",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"CData"}]}]}],["FFI_C.CFnPtr",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.CFnPtr"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFI_C.C_Any",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_Any"}]}]}],["FFI_C.C_CData",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_CData"}]}]}],["FFI_C.C_Float",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_Float"}]}]}],["FFI_C.C_Fn",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_Fn"}]}]}],["FFI_C.C_FnBase",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_FnBase"}]}]}],["FFI_C.C_FnIO",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_FnIO"}]}]}],["FFI_C.C_FnT",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_FnT"}]}]}],["FFI_C.C_FnTypes",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_FnTypes"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFI_C.C_IntBits16",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_IntBits16"}]}]}],["FFI_C.C_IntBits32",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_IntBits32"}]}]}],["FFI_C.C_IntBits64",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_IntBits64"}]}]}],["FFI_C.C_IntBits8",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_IntBits8"}]}]}],["FFI_C.C_IntChar",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_IntChar"}]}]}],["FFI_C.C_IntNative",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_IntNative"}]}]}],["FFI_C.C_IntT",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_IntT"}]}]}],["FFI_C.C_IntTypes",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_IntTypes"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFI_C.C_MPtr",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_MPtr"}]}]}],["FFI_C.C_Ptr",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_Ptr"}]}]}],["FFI_C.C_Str",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_Str"}]}]}],["FFI_C.C_Types",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_Types"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFI_C.C_Unit",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.C_Unit"}]}]}],["Language.Reflection.Errors.CantConvert",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.CantConvert"}]}]}],["Language.Reflection.Errors.CantInferType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.CantInferType"}]}]}],["Language.Reflection.Errors.CantIntroduce",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.CantIntroduce"}]}]}],["Language.Reflection.Errors.CantMatch",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.CantMatch"}]}]}],["Language.Reflection.Errors.CantResolve",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.CantResolve"}]}]}],["Language.Reflection.Errors.CantResolveAlts",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.CantResolveAlts"}]}]}],["Language.Reflection.Errors.CantSolveGoal",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.CantSolveGoal"}]}]}],["Language.Reflection.Errors.CantUnify",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.CantUnify"}]}]}],["Language.Reflection.Case",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Case"}]}]}],["Language.Reflection.CaseN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.CaseN"}]}]}],["Prelude.Cast.Cast",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Cast.Cast"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.Ch",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Ch"}]}]}],["Language.Reflection.Claim",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Claim"}]}]}],["Prelude.Nat.CmpEQ",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.CmpEQ"}]}]}],["Prelude.Nat.CmpGT",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.CmpGT"}]}]}],["Prelude.Nat.CmpLT",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.CmpLT"}]}]}],["Prelude.Nat.CmpNat",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.CmpNat"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Main.Com",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.Com"},{"tag":"ComVar","contents":"var.0"}]}]}],["Main.ComChar",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ComChar"}]}]}],["Main.ComDouble",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ComDouble"}]}]}],["Main.ComFun",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ComFun"}]}]}],["Main.ComInt",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ComInt"}]}]}],["Main.ComPtr",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ComPtr"}]}]}],["Main.ComRaw",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ComRaw"}]}]}],["Main.ComStr",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ComStr"}]}]}],["Main.ComUInt",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ComUInt"}]}]}],["Main.ComUnit",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ComUnit"}]}]}],["Main.Com_Fn",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.Com_Fn"},{"tag":"ComVar","contents":"var.0"}]}]}],["Main.Com_FnBase",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.Com_FnBase"}]}]}],["Main.Com_FnIO",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.Com_FnIO"}]}]}],["Main.Com_Fun",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.Com_Fun"}]}]}],["Main.Com_FunTypes",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.Com_FunTypes"},{"tag":"ComVar","contents":"var.0"}]}]}],["Main.Com_Raw",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.Com_Raw"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Compute",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Compute"}]}]}],["Language.Reflection.Const",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Const"}]}]}],["Language.Reflection.Elab.Constraint",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Constraint"}]}]}],["Language.Reflection.Elab.Constructor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Constructor"}]}]}],["Language.Reflection.Elab.ConstructorDefn",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.ConstructorDefn"}]}]}],["Language.Reflection.Elab.CtorArg",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.CtorArg"}]}]}],["Language.Reflection.Elab.CtorField",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.CtorField"}]}]}],["Language.Reflection.Elab.CtorParameter",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.CtorParameter"}]}]}],["Language.Reflection.DCon",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.DCon"}]}]}],["Prelude.File.DHandle",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.DHandle"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFI_Export.DHere",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.DHere"}]}]}],["Builtins.DPair",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Builtins.DPair"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["FFI_Export.DThere",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.DThere"}]}]}],["FFI_Export.Data",{"tag":"ComFun","contents":[["var.0","var.1","var.2"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.Data"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"}]}]}],["FFI_Export.DataDefined",{"tag":"ComFun","contents":[["var.0","var.1","var.2","var.3"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.DataDefined"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"},{"tag":"ComVar","contents":"var.3"}]}]}],["Language.Reflection.Elab.DataDefn",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.DataDefn"}]}]}],["Language.Reflection.Elab.Datatype",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Datatype"}]}]}],["Prelude.Basics.Dec",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Basics.Dec"},{"tag":"ComVar","contents":"var.0"}]}]}],["Decidable.Equality.DecEq",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Decidable.Equality.DecEq"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Elab.Declare",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Declare"}]}]}],["Language.Reflection.Elab.DefineDatatype",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.DefineDatatype"}]}]}],["Language.Reflection.Elab.DefineFun",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.DefineFun"}]}]}],["Delay",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Delay"}]}]}],["DelayReason",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"DelayReason"}]}]}],["Delayed",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Delayed"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Prelude.File.Directory",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.Directory"}]}]}],["Prelude.Show.Dollar",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.Dollar"}]}]}],["Prelude.Interfaces.EQ",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.EQ"}]}]}],["Prelude.Either.Either",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Either.Either"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.Elab.Elab",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Elab"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Pairs.Element",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Pairs.Element"}]}]}],["FFI_Export.End",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.End"}]}]}],["Prelude.Enum",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Enum"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Interfaces.Eq",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Eq"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Show.Eq",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.Eq"}]}]}],["Language.Reflection.Elab.Erased",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Erased"}]}]}],["Language.Reflection.Erased",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Erased"}]}]}],["Language.Reflection.Elab.Erasure",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Erasure"}]}]}],["Language.Reflection.Errors.Err",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.Err"}]}]}],["Prelude.Providers.Error",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Providers.Error"}]}]}],["Language.Reflection.ErrorReportPart",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ErrorReportPart"}]}]}],["Prelude.Pairs.Evidence",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Pairs.Evidence"}]}]}],["Language.Reflection.Exact",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Exact"}]}]}],["Prelude.Pairs.Exists",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Pairs.Exists"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.Elab.Explicit",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Explicit"}]}]}],["ForeignEnv.FEnv",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"ForeignEnv.FEnv"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["FFI",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI"}]}]}],["FFI_Export.FFI_Base",{"tag":"ComFun","contents":[["var.0","var.1","var.2"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.FFI_Base"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"}]}]}],["FFI_Export.FFI_ExpType",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.FFI_ExpType"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["FFI_Export.FFI_Export",{"tag":"ComFun","contents":[["var.0","var.1","var.2"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.FFI_Export"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"}]}]}],["FFI_Export.FFI_Exportable",{"tag":"ComFun","contents":[["var.0","var.1","var.2"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.FFI_Exportable"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"}]}]}],["FFI_Export.FFI_Fun",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.FFI_Fun"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["FFI_Export.FFI_IO",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.FFI_IO"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFI_Export.FFI_Prim",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.FFI_Prim"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFI_Export.FFI_Ret",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.FFI_Ret"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFun",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFun"}]}]}],["Prelude.File.FHandle",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.FHandle"},{"tag":"ComVar","contents":"var.0"}]}]}],["FRet",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FRet"}]}]}],["FTy",{"tag":"ComFun","contents":[["var.0","var.1","var.2"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FTy"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"}]}]}],["Language.Reflection.Fail",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Fail"}]}]}],["Prelude.Bool.False",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Bool.False"}]}]}],["Prelude.File.File",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.File"}]}]}],["Prelude.File.FileError",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.FileError"}]}]}],["Main.FileHandler",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.FileHandler"}]}]}],["Language.Reflection.FileLoc",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.FileLoc"}]}]}],["Prelude.File.FileNotFound",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.FileNotFound"}]}]}],["Prelude.File.FileReadError",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.FileReadError"}]}]}],["Prelude.File.FileWriteError",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.FileWriteError"}]}]}],["Language.Reflection.Fill",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Fill"}]}]}],["Language.Reflection.Elab.Fixity",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Fixity"}]}]}],["Language.Reflection.Fl",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Fl"}]}]}],["Language.Reflection.Focus",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Focus"}]}]}],["Prelude.Foldable.Foldable",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Foldable.Foldable"},{"tag":"ComVar","contents":"var.0"}]}]}],["Main.ForeignName",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.ForeignName"}]}]}],["Language.Reflection.Forgot",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Forgot"}]}]}],["Prelude.Interfaces.Fractional",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Fractional"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFI_Export.Fun",{"tag":"ComFun","contents":[["var.0","var.1","var.2","var.3"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_Export.Fun"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"},{"tag":"ComVar","contents":"var.3"}]}]}],["Language.Reflection.Elab.FunArg",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.FunArg"}]}]}],["Language.Reflection.Elab.FunClause",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.FunClause"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Elab.FunDefn",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.FunDefn"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Functor.Functor",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Functor.Functor"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.GHole",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.GHole"}]}]}],["Prelude.Interfaces.GT",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.GT"}]}]}],["Prelude.File.GenericFileError",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.GenericFileError"}]}]}],["Prelude.Nat.GetAdditive",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.GetAdditive"}]}]}],["Prelude.Nat.GetMultiplicative",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.GetMultiplicative"}]}]}],["Language.Reflection.GoalType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.GoalType"}]}]}],["Language.Reflection.Guess",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Guess"}]}]}],["Language.Reflection.Hole",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Hole"}]}]}],["Language.Reflection.I",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.I"}]}]}],["IO'",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"IO'"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.IT16",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.IT16"}]}]}],["Language.Reflection.IT32",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.IT32"}]}]}],["Language.Reflection.IT64",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.IT64"}]}]}],["Language.Reflection.IT8",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.IT8"}]}]}],["Language.Reflection.ITBig",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ITBig"}]}]}],["Language.Reflection.ITChar",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ITChar"}]}]}],["Language.Reflection.ITFixed",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ITFixed"}]}]}],["Language.Reflection.ITNative",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ITNative"}]}]}],["Language.Reflection.Implementation",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Implementation"}]}]}],["Language.Reflection.ImplementationCtorN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ImplementationCtorN"}]}]}],["Language.Reflection.ImplementationN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ImplementationN"}]}]}],["Language.Reflection.Elab.Implicit",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Implicit"}]}]}],["Prelude.List.InBounds",{"tag":"ComFun","contents":[["var.0","var.1","var.2"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.List.InBounds"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"},{"tag":"ComVar","contents":"var.2"}]}]}],["Prelude.List.InFirst",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.List.InFirst"}]}]}],["Prelude.List.InLater",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.List.InLater"}]}]}],["Language.Reflection.Errors.Inaccessible",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.Inaccessible"}]}]}],["Language.Reflection.Errors.IncompleteTerm",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.IncompleteTerm"}]}]}],["Language.Reflection.Induction",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Induction"}]}]}],["Infinite",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Infinite"}]}]}],["Language.Reflection.Errors.InfiniteUnify",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.InfiniteUnify"}]}]}],["Language.Reflection.Elab.Infix",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Infix"}]}]}],["Language.Reflection.Elab.Infixl",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Infixl"}]}]}],["Language.Reflection.Elab.Infixr",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Infixr"}]}]}],["Language.Reflection.IntTy",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.IntTy"}]}]}],["Prelude.Interfaces.Integral",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Integral"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Errors.InternalMsg",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.InternalMsg"}]}]}],["Language.Reflection.Intro",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Intro"}]}]}],["Language.Reflection.Intros",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Intros"}]}]}],["Language.Reflection.Errors.InvalidTCArg",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.InvalidTCArg"}]}]}],["Prelude.Maybe.IsJust",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Maybe.IsJust"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Prelude.List.IsNonEmpty",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.List.IsNonEmpty"}]}]}],["Prelude.Nat.IsSucc",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.IsSucc"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Maybe.ItIsJust",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Maybe.ItIsJust"}]}]}],["Prelude.Nat.ItIsSucc",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.ItIsSucc"}]}]}],["JS_Float",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_Float"}]}]}],["JS_Fn",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_Fn"}]}]}],["JS_FnBase",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_FnBase"}]}]}],["JS_FnIO",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_FnIO"}]}]}],["JS_FnT",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_FnT"}]}]}],["JS_FnTypes",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_FnTypes"},{"tag":"ComVar","contents":"var.0"}]}]}],["JS_IntChar",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_IntChar"}]}]}],["JS_IntNative",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_IntNative"}]}]}],["JS_IntT",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_IntT"}]}]}],["JS_IntTypes",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_IntTypes"},{"tag":"ComVar","contents":"var.0"}]}]}],["JS_Ptr",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_Ptr"}]}]}],["JS_Str",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_Str"}]}]}],["JS_Types",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_Types"},{"tag":"ComVar","contents":"var.0"}]}]}],["JS_Unit",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JS_Unit"}]}]}],["JsFn",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"JsFn"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Maybe.Just",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Maybe.Just"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Interfaces.LT",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.LT"}]}]}],["Prelude.Nat.LTE",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.LTE"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Prelude.Nat.LTESucc",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.LTESucc"}]}]}],["Prelude.Nat.LTEZero",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.LTEZero"}]}]}],["Language.Reflection.Lam",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Lam"}]}]}],["LazyValue",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"LazyValue"}]}]}],["Prelude.Either.Left",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Either.Left"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Nat.LeftIsNotZero",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.LeftIsNotZero"}]}]}],["Language.Reflection.Let",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Let"}]}]}],["Language.Reflection.LetTac",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.LetTac"}]}]}],["Language.Reflection.LetTacTy",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.LetTacTy"}]}]}],["Main.Library",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.Library"}]}]}],["Prelude.List.List",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.List.List"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Errors.LoadingFailed",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.LoadingFailed"}]}]}],["Language.Reflection.MN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.MN"}]}]}],["ManagedPtr",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"ManagedPtr"}]}]}],["Prelude.Interfaces.MaxBound",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.MaxBound"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Maybe.Maybe",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Maybe.Maybe"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.MetaN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.MetaN"}]}]}],["Language.Reflection.MethodN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.MethodN"}]}]}],["Prelude.Interfaces.MinBound",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.MinBound"},{"tag":"ComVar","contents":"var.0"}]}]}],["FFI_C.MkCFnPtr",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.MkCFnPtr"},{"tag":"ComVar","contents":"var.0"}]}]}],["Main.MkComFn",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.MkComFn"}]}]}],["Main.MkComRaw",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.MkComRaw"}]}]}],["Builtins.MkDPair",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Builtins.MkDPair"}]}]}],["Language.Reflection.Elab.MkDatatype",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.MkDatatype"}]}]}],["MkFFI",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"MkFFI"}]}]}],["Language.Reflection.Elab.MkFunArg",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.MkFunArg"}]}]}],["Language.Reflection.Elab.MkFunClause",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.MkFunClause"}]}]}],["MkIO",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"MkIO"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Elab.MkImpossibleClause",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.MkImpossibleClause"}]}]}],["MkJsFn",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"MkJsFn"},{"tag":"ComVar","contents":"var.0"}]}]}],["Builtins.MkPair",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Builtins.MkPair"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["FFI_C.MkRaw",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.MkRaw"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Strings.MkString",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Strings.MkString"}]}]}],["Main.MkUInt",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.MkUInt"}]}]}],["Builtins.MkUPair",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Builtins.MkUPair"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["MkUnit",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"MkUnit"}]}]}],["Prelude.File.Mode",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.Mode"}]}]}],["Prelude.Monad.Monad",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Monad.Monad"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Algebra.Monoid",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Algebra.Monoid"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Errors.Msg",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.Msg"}]}]}],["Prelude.Nat.Multiplicative",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.Multiplicative"}]}]}],["Language.Reflection.NS",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.NS"}]}]}],["Language.Reflection.NamePart",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.NamePart"}]}]}],["Language.Reflection.NameType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.NameType"}]}]}],["Prelude.Nat.Nat",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.Nat"}]}]}],["Language.Reflection.NativeTy",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.NativeTy"}]}]}],["Prelude.Interfaces.Neg",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Neg"},{"tag":"ComVar","contents":"var.0"}]}]}],["ForeignEnv.Nil",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"ForeignEnv.Nil"}]}]}],["Prelude.List.Nil",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.List.Nil"}]}]}],["Prelude.Basics.No",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Basics.No"}]}]}],["Language.Reflection.Errors.NoRewriting",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.NoRewriting"}]}]}],["Language.Reflection.Errors.NoSuchVariable",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.NoSuchVariable"}]}]}],["Language.Reflection.Errors.NoTypeDecl",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.NoTypeDecl"}]}]}],["Language.Reflection.Errors.NoValidAlts",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.NoValidAlts"}]}]}],["Language.Reflection.Errors.NonCollapsiblePostulate",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.NonCollapsiblePostulate"}]}]}],["Prelude.List.NonEmpty",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.List.NonEmpty"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.Errors.NonFunctionType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.NonFunctionType"}]}]}],["Prelude.Nat.NotBothZero",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.NotBothZero"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.Errors.NotEquality",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.NotEquality"}]}]}],["Language.Reflection.Elab.NotErased",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.NotErased"}]}]}],["Language.Reflection.Errors.NotInjective",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.NotInjective"}]}]}],["Prelude.Maybe.Nothing",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Maybe.Nothing"}]}]}],["Language.Reflection.NullType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.NullType"}]}]}],["Prelude.Interfaces.Num",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Num"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Show.Open",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.Open"}]}]}],["Prelude.Interfaces.Ord",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Ord"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Interfaces.Ordering",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Ordering"}]}]}],["Language.Reflection.P",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.P"}]}]}],["Language.Reflection.PVTy",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.PVTy"}]}]}],["Language.Reflection.PVar",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.PVar"}]}]}],["Builtins.Pair",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Builtins.Pair"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.ParentN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ParentN"}]}]}],["Prelude.File.PermissionDenied",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.PermissionDenied"}]}]}],["Language.Reflection.Pi",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Pi"}]}]}],["Language.Reflection.Elab.Plicity",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Plicity"}]}]}],["Prelude.Show.Prec",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.Prec"}]}]}],["Language.Reflection.Elab.Prefix",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prefix"}]}]}],["Prelude.Show.PrefixMinus",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.PrefixMinus"}]}]}],["PrimIO",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"PrimIO"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Elab.Prim__AddImplementation",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__AddImplementation"}]}]}],["Language.Reflection.Elab.Prim__Apply",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Apply"}]}]}],["Language.Reflection.Elab.Prim__Attack",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Attack"}]}]}],["Language.Reflection.Elab.Prim__BindElab",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__BindElab"}]}]}],["Language.Reflection.Elab.Prim__Check",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Check"}]}]}],["Language.Reflection.Elab.Prim__Claim",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Claim"}]}]}],["Language.Reflection.Elab.Prim__Compute",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Compute"}]}]}],["Language.Reflection.Elab.Prim__Converts",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Converts"}]}]}],["Language.Reflection.Elab.Prim__Debug",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Debug"}]}]}],["Language.Reflection.Elab.Prim__DeclareDatatype",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__DeclareDatatype"}]}]}],["Language.Reflection.Elab.Prim__DeclareType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__DeclareType"}]}]}],["Language.Reflection.Elab.Prim__DefineDatatype",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__DefineDatatype"}]}]}],["Language.Reflection.Elab.Prim__DefineFunction",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__DefineFunction"}]}]}],["Language.Reflection.Elab.Prim__Env",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Env"}]}]}],["Language.Reflection.Elab.Prim__Fail",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Fail"}]}]}],["Language.Reflection.Elab.Prim__Fill",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Fill"}]}]}],["Language.Reflection.Elab.Prim__Fixity",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Fixity"}]}]}],["Language.Reflection.Elab.Prim__Focus",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Focus"}]}]}],["Language.Reflection.Elab.Prim__Forall",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Forall"}]}]}],["Language.Reflection.Elab.Prim__Gensym",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Gensym"}]}]}],["Language.Reflection.Elab.Prim__Goal",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Goal"}]}]}],["Language.Reflection.Elab.Prim__Guess",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Guess"}]}]}],["Language.Reflection.Elab.Prim__Holes",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Holes"}]}]}],["Prim__IO",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prim__IO"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Elab.Prim__Intro",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Intro"}]}]}],["Language.Reflection.Elab.Prim__IsTCName",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__IsTCName"}]}]}],["Language.Reflection.Elab.Prim__LetBind",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__LetBind"}]}]}],["Language.Reflection.Elab.Prim__LookupArgs",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__LookupArgs"}]}]}],["Language.Reflection.Elab.Prim__LookupDatatype",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__LookupDatatype"}]}]}],["Language.Reflection.Elab.Prim__LookupFunDefn",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__LookupFunDefn"}]}]}],["Language.Reflection.Elab.Prim__LookupTy",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__LookupTy"}]}]}],["Language.Reflection.Elab.Prim__MatchApply",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__MatchApply"}]}]}],["Language.Reflection.Elab.Prim__Metavar",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Metavar"}]}]}],["Language.Reflection.Elab.Prim__Namespace",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Namespace"}]}]}],["Language.Reflection.Elab.Prim__Normalise",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Normalise"}]}]}],["Language.Reflection.Elab.Prim__PatBind",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__PatBind"}]}]}],["Language.Reflection.Elab.Prim__PatVar",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__PatVar"}]}]}],["Language.Reflection.Elab.Prim__PureElab",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__PureElab"}]}]}],["Language.Reflection.Elab.Prim__RecursiveElab",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__RecursiveElab"}]}]}],["Language.Reflection.Elab.Prim__ResolveTC",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__ResolveTC"}]}]}],["Language.Reflection.Elab.Prim__Rewrite",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Rewrite"}]}]}],["Language.Reflection.Elab.Prim__Search",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Search"}]}]}],["Language.Reflection.Elab.Prim__Solve",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Solve"}]}]}],["Language.Reflection.Elab.Prim__SourceLocation",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__SourceLocation"}]}]}],["Language.Reflection.Elab.Prim__Try",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Try"}]}]}],["Language.Reflection.Elab.Prim__TryCatch",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__TryCatch"}]}]}],["Language.Reflection.Elab.Prim__Unfocus",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Unfocus"}]}]}],["Language.Reflection.Elab.Prim__Whnf",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.Prim__Whnf"}]}]}],["Language.Reflection.Errors.ProgramLineComment",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.ProgramLineComment"}]}]}],["Language.Reflection.Errors.ProofSearchFail",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.ProofSearchFail"}]}]}],["Prelude.Providers.Provide",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Providers.Provide"}]}]}],["Prelude.Providers.Provider",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Providers.Provider"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Errors.ProviderError",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.ProviderError"}]}]}],["Ptr",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Ptr"}]}]}],["Language.Reflection.Quotable",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Quotable"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.RApp",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.RApp"}]}]}],["Language.Reflection.RBind",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.RBind"}]}]}],["Language.Reflection.RConstant",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.RConstant"}]}]}],["Language.Reflection.RType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.RType"}]}]}],["Language.Reflection.RUType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.RUType"}]}]}],["FFI_C.Raw",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"FFI_C.Raw"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Raw",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Raw"}]}]}],["Language.Reflection.RawPart",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.RawPart"}]}]}],["Prelude.File.Read",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.Read"}]}]}],["Ownership.Read",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Ownership.Read"}]}]}],["Prelude.File.ReadAppend",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.ReadAppend"}]}]}],["Prelude.File.ReadWrite",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.ReadWrite"}]}]}],["Prelude.File.ReadWriteTruncate",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.ReadWriteTruncate"}]}]}],["Language.Reflection.Ref",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Ref"}]}]}],["Language.Reflection.Refine",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Refine"}]}]}],["Refl",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Refl"}]}]}],["Language.Reflection.ReflConst",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ReflConst"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Reflect",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Reflect"}]}]}],["Language.Reflection.Rewrite",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Rewrite"}]}]}],["Prelude.Either.Right",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Either.Right"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Nat.RightIsNotZero",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.RightIsNotZero"}]}]}],["Prelude.Nat.S",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.S"}]}]}],["Language.Reflection.SN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.SN"}]}]}],["Language.Reflection.Search",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Search"}]}]}],["Prelude.Algebra.Semigroup",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Algebra.Semigroup"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Seq",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Seq"}]}]}],["Prelude.Show.Show",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.Show"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.WellFounded.Sized",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.WellFounded.Sized"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Skip",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Skip"}]}]}],["Language.Reflection.Solve",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Solve"}]}]}],["Language.Reflection.SourceFC",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.SourceFC"}]}]}],["Language.Reflection.SourceLocation",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.SourceLocation"}]}]}],["Language.Reflection.SpecialName",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.SpecialName"}]}]}],["Language.Reflection.Str",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Str"}]}]}],["Prelude.Strings.StrCons",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Strings.StrCons"}]}]}],["Prelude.Strings.StrM",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Strings.StrM"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Strings.StrNil",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Strings.StrNil"}]}]}],["Language.Reflection.StrType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.StrType"}]}]}],["Prelude.Stream.Stream",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Stream.Stream"},{"tag":"ComVar","contents":"var.0"}]}]}],["Prelude.Strings.StringBuffer",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Strings.StringBuffer"}]}]}],["Language.Reflection.SubReport",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.SubReport"}]}]}],["Prelude.Pairs.Subset",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Pairs.Subset"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Symbol_",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Symbol_"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.TCon",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.TCon"}]}]}],["Language.Reflection.TConst",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.TConst"}]}]}],["Language.Reflection.TT",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.TT"}]}]}],["Language.Reflection.TTName",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.TTName"}]}]}],["Language.Reflection.TTUExp",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.TTUExp"}]}]}],["Language.Reflection.TType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.TType"}]}]}],["Language.Reflection.Tactic",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Tactic"}]}]}],["Language.Reflection.TermPart",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.TermPart"}]}]}],["Language.Reflection.TextPart",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.TextPart"}]}]}],["TheWorld",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"TheWorld"}]}]}],["Language.Reflection.TheWorld",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.TheWorld"}]}]}],["Language.Reflection.Errors.TooManyArguments",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.TooManyArguments"}]}]}],["Prelude.Traversable.Traversable",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Traversable.Traversable"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.Trivial",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Trivial"}]}]}],["Prelude.Bool.True",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Bool.True"}]}]}],["Language.Reflection.Try",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Try"}]}]}],["Language.Reflection.Elab.TyConArg",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.TyConArg"}]}]}],["Language.Reflection.Elab.TyConIndex",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.TyConIndex"}]}]}],["Language.Reflection.Elab.TyConParameter",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.TyConParameter"}]}]}],["Language.Reflection.Elab.TyDecl",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Elab.TyDecl"}]}]}],["Main.UInt",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Main.UInt"}]}]}],["Language.Reflection.UN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.UN"}]}]}],["Builtins.UPair",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Builtins.UPair"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.UType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.UType"}]}]}],["Language.Reflection.UVal",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.UVal"}]}]}],["Language.Reflection.UVar",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.UVar"}]}]}],["Language.Reflection.Unfocus",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Unfocus"}]}]}],["Language.Reflection.Errors.UnifyScope",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.UnifyScope"}]}]}],["Prelude.Uninhabited.Uninhabited",{"tag":"ComFun","contents":[["var.0"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Uninhabited.Uninhabited"},{"tag":"ComVar","contents":"var.0"}]}]}],["Language.Reflection.UniqueType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.UniqueType"}]}]}],["Unit",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Unit"}]}]}],["Language.Reflection.Universe",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Universe"}]}]}],["Language.Reflection.Errors.UniverseError",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.UniverseError"}]}]}],["Language.Reflection.Errors.UnknownImplicit",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.UnknownImplicit"}]}]}],["Prelude.Show.User",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.User"}]}]}],["Language.Reflection.V",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.V"}]}]}],["Language.Reflection.Var",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Var"}]}]}],["Void",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Void"}]}]}],["Language.Reflection.VoidType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.VoidType"}]}]}],["Prelude.WellFounded.WellFounded",{"tag":"ComFun","contents":[["var.0","var.1"],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.WellFounded.WellFounded"},{"tag":"ComVar","contents":"var.0"},{"tag":"ComVar","contents":"var.1"}]}]}],["Language.Reflection.WhereN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.WhereN"}]}]}],["Language.Reflection.Errors.WithFnType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Errors.WithFnType"}]}]}],["Language.Reflection.WithN",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.WithN"}]}]}],["World",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"World"}]}]}],["Language.Reflection.WorldType",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.WorldType"}]}]}],["Prelude.File.WriteTruncate",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.File.WriteTruncate"}]}]}],["Prelude.Basics.Yes",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Basics.Yes"}]}]}],["Prelude.Nat.Z",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Nat.Z"}]}]}],["assert_unreachable",{"tag":"ComFun","contents":[[],{"tag":"ComNil"}]}],["call__IO",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"{APPLY_0}"},[{"tag":"ComVar","contents":"{arg_2}"},{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"TheWorld"}]}]]}]}],["idris_crash",{"tag":"ComFun","contents":[[],{"tag":"ComNil"}]}],["io_bind",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}","{k_4}","{w_5}"],{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"{APPLY_0}"},[{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"{APPLY_0}"},[{"tag":"ComVar","contents":"{k_4}"},{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"{APPLY_0}"},[{"tag":"ComVar","contents":"{arg_3}"},{"tag":"ComVar","contents":"{w_5}"}]]}]]},{"tag":"ComVar","contents":"{w_5}"}]]}]}],["Main.main",{"tag":"ComFun","contents":[["{in_0}"],{"tag":"ComLet","contents":["{in_1}",{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"Main.openFile"},[{"tag":"ComStr","contents":"./text.txt"},{"tag":"ComVar","contents":"{in_0}"}]]},{"tag":"ComLet","contents":["{in_2}",{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"Main.readFile"},[{"tag":"ComVar","contents":"{in_1}"},{"tag":"ComVar","contents":"{in_0}"}]]},{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"Main.println"},[{"tag":"ComVar","contents":"{in_2}"},{"tag":"ComVar","contents":"{in_0}"}]]}]}]}]}],["mkForeignPrim",{"tag":"ComFun","contents":[[],{"tag":"ComNil"}]}],["Main.openFile",{"tag":"ComFun","contents":[["{arg_0}","{w_1}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"builtin-simple_open"},[{"tag":"ComVar","contents":"{arg_0}"}]]}]}],["prim__asPtr",{"tag":"ComFun","contents":[["{arg_0}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"}]]}]}],["prim__eqManagedPtr",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"}]]}]}],["prim__eqPtr",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"}]]}]}],["prim__managedNull",{"tag":"ComFun","contents":[[],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[]]}]}],["prim__null",{"tag":"ComFun","contents":[[],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[]]}]}],["prim__peek16",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["prim__peek32",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["prim__peek64",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["prim__peek8",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["prim__peekDouble",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["prim__peekPtr",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["prim__peekSingle",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["prim__poke16",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"},{"tag":"ComVar","contents":"{arg_3}"}]]}]}],["prim__poke32",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"},{"tag":"ComVar","contents":"{arg_3}"}]]}]}],["prim__poke64",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"},{"tag":"ComVar","contents":"{arg_3}"}]]}]}],["prim__poke8",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"},{"tag":"ComVar","contents":"{arg_3}"}]]}]}],["prim__pokeDouble",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"},{"tag":"ComVar","contents":"{arg_3}"}]]}]}],["prim__pokePtr",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"},{"tag":"ComVar","contents":"{arg_3}"}]]}]}],["prim__pokeSingle",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"},{"tag":"ComVar","contents":"{arg_3}"}]]}]}],["prim__ptrOffset",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"}]]}]}],["prim__readChars",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["prim__readFile",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"}]]}]}],["prim__registerPtr",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"}]]}]}],["prim__sizeofPtr",{"tag":"ComFun","contents":[[],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[]]}]}],["prim__stderr",{"tag":"ComFun","contents":[[],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[]]}]}],["prim__stdin",{"tag":"ComFun","contents":[[],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[]]}]}],["prim__stdout",{"tag":"ComFun","contents":[[],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[]]}]}],["prim__vm",{"tag":"ComFun","contents":[["{arg_0}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"}]]}]}],["prim__writeFile",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"prim-external"},[{"tag":"ComVar","contents":"{arg_0}"},{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["prim_io_bind",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}"],{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"{APPLY_0}"},[{"tag":"ComVar","contents":"{arg_3}"},{"tag":"ComVar","contents":"{arg_2}"}]]}]}],["Main.println",{"tag":"ComFun","contents":[["{arg_0}","{w_1}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"builtin-println"},[{"tag":"ComVar","contents":"{arg_0}"}]]}]}],["Main.readFile",{"tag":"ComFun","contents":[["{arg_0}","{w_1}"],{"tag":"ComApp","contents":[{"tag":"ComInternal","contents":"builtin-simple_read"},[{"tag":"ComVar","contents":"{arg_0}"}]]}]}],["run__IO",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}"],{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"{APPLY_0}"},[{"tag":"ComVar","contents":"{arg_1}"},{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"TheWorld"}]}]]}]}],["unsafePerformPrimIO",{"tag":"ComFun","contents":[[],{"tag":"ComNil"}]}],["{APPLY_0}",{"tag":"ComFun","contents":[["{fn_0}","{arg_0}"],{"tag":"ComNil"}]}],["{APPLY2_0}",{"tag":"ComFun","contents":[["{fn_0}","{arg0_0}","{arg1_0}"],{"tag":"ComNil"}]}],["{EVAL_0}",{"tag":"ComFun","contents":[["{arg_0}"],{"tag":"ComVar","contents":"{arg_0}"}]}],["{__Infer_0}",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"{__Infer_0}"}]}]}],["{__infer_0}",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"{__infer_0}"}]}]}],["{runMain_0}",{"tag":"ComFun","contents":[[],{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"{EVAL_0}"},[{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"Main.main"},[{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"TheWorld"}]}]]}]]}]}],["io_bind_IO__idr_108_34_108_36_case",{"tag":"ComFun","contents":[["{arg_0}","{arg_1}","{arg_2}","{arg_3}","{arg_4}","{arg_5}","{arg_6}","{arg_7}"],{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"{APPLY_0}"},[{"tag":"ComVar","contents":"{arg_7}"},{"tag":"ComVar","contents":"{arg_5}"}]]}]}],["Prelude.Interfaces.Abs_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Abs_ictor"}]}]}],["Prelude.Applicative.Alternative_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Applicative.Alternative_ictor"}]}]}],["Prelude.Applicative.Applicative_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Applicative.Applicative_ictor"}]}]}],["Prelude.Cast.Cast_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Cast.Cast_ictor"}]}]}],["Decidable.Equality.DecEq_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Decidable.Equality.DecEq_ictor"}]}]}],["Prelude.Enum_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Enum_ictor"}]}]}],["Prelude.Interfaces.Eq_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Eq_ictor"}]}]}],["Prelude.Foldable.Foldable_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Foldable.Foldable_ictor"}]}]}],["Prelude.Interfaces.Fractional_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Fractional_ictor"}]}]}],["Prelude.Functor.Functor_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Functor.Functor_ictor"}]}]}],["Prelude.Interfaces.Integral_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Integral_ictor"}]}]}],["Prelude.Interfaces.MaxBound_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.MaxBound_ictor"}]}]}],["Prelude.Interfaces.MinBound_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.MinBound_ictor"}]}]}],["Prelude.Monad.Monad_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Monad.Monad_ictor"}]}]}],["Prelude.Algebra.Monoid_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Algebra.Monoid_ictor"}]}]}],["Prelude.Interfaces.Neg_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Neg_ictor"}]}]}],["Prelude.Interfaces.Num_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Num_ictor"}]}]}],["Prelude.Interfaces.Ord_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Interfaces.Ord_ictor"}]}]}],["Language.Reflection.Quotable_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.Quotable_ictor"}]}]}],["Language.Reflection.ReflConst_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Language.Reflection.ReflConst_ictor"}]}]}],["Prelude.Algebra.Semigroup_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Algebra.Semigroup_ictor"}]}]}],["Prelude.Show.Show_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Show.Show_ictor"}]}]}],["Prelude.WellFounded.Sized_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.WellFounded.Sized_ictor"}]}]}],["Prelude.Traversable.Traversable_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Traversable.Traversable_ictor"}]}]}],["Prelude.Uninhabited.Uninhabited_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.Uninhabited.Uninhabited_ictor"}]}]}],["Prelude.WellFounded.WellFounded_ictor",{"tag":"ComFun","contents":[[],{"tag":"ComTuple","contents":[{"tag":"ComStr","contents":"Prelude.WellFounded.WellFounded_ictor"}]}]}]],{"tag":"ComApp","contents":[{"tag":"ComVar","contents":"{runMain_0}"},[]]}]} -------------------------------------------------------------------------------- /cam-julia/test/text.txt: -------------------------------------------------------------------------------- 1 | 啊,太懂了!太懂Idris Julia辣! -------------------------------------------------------------------------------- /examples/a.idr: -------------------------------------------------------------------------------- 1 | module Main 2 | import Data.Vect 3 | 4 | public export 5 | 6 | len : Vect n a -> Int 7 | len {n=Z} [] = 0 8 | len {n=S k} (with Vect x::xs) = 1 + len xs 9 | 10 | v : Vect ?n Int 11 | v = [1, 2, 3] 12 | 13 | main : IO () 14 | main = do 15 | putStrLn . show $ len v 16 | putStrLn .show $ with List ["a"] 17 | pure () 18 | 19 | -------------------------------------------------------------------------------- /examples/pair.idr: -------------------------------------------------------------------------------- 1 | module Main 2 | 3 | fred : (String, Int) 4 | fred = ("Fred", 42) 5 | 6 | main : IO () 7 | main = do 8 | putStrLn . show $ fred 9 | pure () -------------------------------------------------------------------------------- /examples/test_ffi.idr: -------------------------------------------------------------------------------- 1 | public export 2 | record UInt where 3 | -- Then we should instance some type class for 4 | -- UInt or other custom primitive types. 5 | -- Note!!! The impl for those primitive types 6 | -- could use foreign functions, which makes it 7 | -- super fast! 8 | constructor MkUInt 9 | i : Int 10 | 11 | 12 | public export 13 | unsigned : Int -> UInt 14 | unsigned = MkUInt 15 | 16 | mutual 17 | public export 18 | data Com_Fn t = MkComFn t 19 | 20 | public export 21 | data Com_Raw t = MkComRaw t 22 | 23 | public export 24 | data Com_FunTypes : Type -> Type where 25 | Com_Fun : Com s -> Com_FunTypes t -> Com_FunTypes (s -> t) 26 | Com_FnIO : Com t -> Com_FunTypes (CamIO t) 27 | Com_FnBase : Com t -> Com_FunTypes t 28 | 29 | public export 30 | data Com : Type -> Type where 31 | ComUnit : Com () 32 | ComStr : Com String 33 | ComDouble : Com Double -- bit -> type 34 | ComInt : Com Int -- bit -> type 35 | ComUInt : Com UInt -- an example of extensive primitive type impl 36 | ComPtr : Com Ptr 37 | ComFun : Com_FunTypes a -> Com (Com_Fn a) 38 | ComChar : Com Char 39 | ComRaw : Com (Com_Raw a) 40 | 41 | public export 42 | data ForeignName 43 | = Builtin String 44 | | Library String String 45 | 46 | 47 | public export 48 | FFICam : FFI 49 | FFICam = MkFFI Com ForeignName String 50 | 51 | public export 52 | CamIO : Type -> Type 53 | CamIO = IO' FFICam 54 | 55 | 56 | %inline 57 | camCall: (ty : Type) -> (fname : ForeignName) -> {auto fty : FTy FFICam [] ty} -> ty 58 | camCall ty fname = foreign FFICam fname ty 59 | 60 | println : String -> CamIO () 61 | println s = camCall (String -> CamIO ()) (Builtin "println") s 62 | 63 | data FileHandler; 64 | 65 | openFile : String -> CamIO (Com_Raw FileHandler) 66 | openFile filename = camCall (String -> CamIO (Com_Raw FileHandler)) (Builtin "simple_open") filename 67 | 68 | readFile : Com_Raw FileHandler -> CamIO String 69 | readFile handle = camCall (Com_Raw FileHandler -> CamIO String) (Builtin "simple_read") handle 70 | 71 | 72 | main : CamIO () 73 | main = do 74 | fh <- openFile "./text.txt" 75 | s <- readFile fh 76 | println s 77 | -------------------------------------------------------------------------------- /idris-cam.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: >= 1.18 2 | name: idris-cam 3 | version: 0.1.0.0 4 | description: Please see the README on GitHub at 5 | homepage: https://github.com/thautwarm/idris-cam#readme 6 | bug-reports: https://github.com/thautwarm/idris-cam/issues 7 | author: thautwarm 8 | maintainer: twshere@outlook.com 9 | copyright: MIT 10 | license: BSD3 11 | license-file: LICENSE 12 | build-type: Simple 13 | extra-source-files: 14 | -- rts/* 15 | README.md 16 | ChangeLog.md 17 | 18 | source-repository head 19 | type: git 20 | location: https://github.com/thautwarm/idris-cam 21 | 22 | executable idris-codegen-cam 23 | main-is: Main.hs 24 | other-modules: 25 | IRTS.CodegenCam 26 | hs-source-dirs: 27 | src 28 | build-depends: 29 | idris 30 | , base 31 | , containers 32 | , directory 33 | , filepath 34 | , haskeline >= 0.7 35 | , mtl 36 | , transformers 37 | , aeson 38 | , text 39 | 40 | if os(linux) 41 | cpp-options: -DLINUX 42 | build-depends: unix < 2.8 43 | if os(freebsd) 44 | cpp-options: -DFREEBSD 45 | build-depends: unix < 2.8 46 | if os(dragonfly) 47 | cpp-options: -DDRAGONFLY 48 | build-depends: unix < 2.8 49 | if os(darwin) 50 | cpp-options: -DMACOSX 51 | build-depends: unix < 2.8 52 | if os(windows) 53 | cpp-options: -DWINDOWS 54 | build-depends: mintty >= 0.1 && < 0.2 55 | , Win32 < 2.7 56 | 57 | ghc-prof-options: -auto-all -caf-all 58 | ghc-options: -threaded -rtsopts -funbox-strict-fields -------------------------------------------------------------------------------- /libs/Cam/Data/Collections.idr: -------------------------------------------------------------------------------- 1 | {- 2 | Extensions for collection interfaces/traits. 3 | 4 | Check following std modules as well: 5 | Prelude.Foldable 6 | , Prelude.Functor 7 | , Prelude.Traversable 8 | , Prelude.WellFounded (Sized) 9 | 10 | -} 11 | module Collections 12 | 13 | import Data.Vect 14 | import Data.HVect 15 | import Prelude 16 | 17 | %hide index 18 | %hide reverse 19 | %access public export 20 | 21 | data TypeHolder : Type -> Type where 22 | MkTypeHolder : (a : Type) -> TypeHolder a 23 | 24 | interface StaticSized c where 25 | typeSize : (TypeHolder c) -> Nat 26 | 27 | interface Indexable c i where 28 | eltype : i -> c -> Type 29 | index : (instI: i) -> (instC: c) -> eltype instI instC 30 | 31 | interface Reversable c1 c2 | c1 where 32 | reverse : c1 -> c2 33 | 34 | ||| implementations for some builtin collection types 35 | 36 | implementation StaticSized (Vect n t) where 37 | typeSize {n} _ = n 38 | 39 | implementation Sized (Vect n t) where 40 | size {n} _ = n 41 | 42 | implementation Indexable (Vect n t) (Fin n) where 43 | eltype {t} _ _ = t 44 | index FZ (x :: xs) = x 45 | index (FS k) (x :: xs) = index k xs 46 | 47 | -- plusZCommu : (n: Nat) -> n = plus n Z 48 | -- plusZCommu Z = Refl 49 | -- plusZCommu (S k) = cong (plusZCommu k) 50 | 51 | -- thanks to ice1000, this is extremely crucial. 52 | appendLast : Vect a n -> n -> Vect (S a) n 53 | appendLast [] x = x :: [] 54 | appendLast (y :: xs) x = y :: appendLast xs x 55 | 56 | reverseVect : Vect a n -> Vect a n 57 | reverseVect [] = [] 58 | reverseVect (x :: xs) = (reverseVect xs) `appendLast` x 59 | 60 | implementation Reversable (Vect n t) (Vect n t) where 61 | reverse = reverseVect 62 | 63 | implementation StaticSized (HVect xs) where 64 | typeSize {xs} _ = size xs 65 | 66 | implementation Sized (HVect xs) where 67 | size {xs} _ = size xs 68 | 69 | implementation Indexable (HVect xs) (Fin (size xs)) where 70 | eltype {xs} fin _ = index fin xs 71 | index FZ (x::xs) = x 72 | index (FS k) (x :: xs) = index k xs 73 | 74 | popPush : (x: t) -> (ys: Vect n2 t) -> (xs: Vect n1 t) -> xs ++ x :: ys = (xs `appendLast` x) ++ ys 75 | popPush x ys [] = Refl 76 | popPush x ys (y :: xs) = rewrite popPush x ys xs in Refl 77 | 78 | vectReverseProp : (x: t) -> (ys: Vect n2 t) -> (xs: Vect n1 t) -> reverseVect xs ++ x :: ys = reverseVect (x :: xs) ++ ys 79 | vectReverseProp x ys xs = 80 | rewrite popPush x ys (reverseVect xs) in Refl 81 | 82 | vectAppendLastProp : (x: t) -> (xs : Vect m t) -> x :: (xs ++ []) = (x :: xs) ++ [] 83 | vectAppendLastProp x xs = Refl 84 | 85 | zeroVectCommutativeProp : (vec: Vect n t) -> vec = vec ++ [] 86 | zeroVectCommutativeProp [] = Refl 87 | zeroVectCommutativeProp (x::xs) = 88 | rewrite zeroVectCommutativeProp xs in vectAppendLastProp x xs 89 | 90 | -- convert implcit vars into the explicit ones and it works, which 91 | --- is the 2nd suggestion from ice1000. 92 | appendHList : (xs1 : Vect n1 Type) -> (xs2 : Vect n2 Type) -> 93 | HVect xs1 -> HVect xs2 -> HVect (reverseVect xs1 ++ xs2) 94 | appendHList [] typs [] lst = lst 95 | appendHList (x1::xs1) xs2 (elt1::lst1) lst2 = 96 | rewrite sym(popPush x1 xs2 (reverseVect xs1)) in 97 | appendHList xs1 (x1::xs2) lst1 (elt1::lst2) 98 | 99 | implementation Reversable (HVect xs) (HVect (reverseVect xs)) where 100 | reverse {xs} lst = 101 | rewrite zeroVectCommutativeProp (reverseVect xs) in 102 | appendHList xs [] lst (with HVect []) 103 | -------------------------------------------------------------------------------- /libs/Cam/Data/Compat.idr: -------------------------------------------------------------------------------- 1 | module Compat 2 | import Data.Vect 3 | import Data.HVect 4 | import Cam.FFI 5 | import Cam.IO 6 | import Cam.Data.Collections 7 | 8 | %access export 9 | 10 | public export 11 | interface Mapping a b | a where 12 | toNative : a -> b 13 | toForeign : b -> a 14 | 15 | implementation Mapping (Boxed Int) Int where 16 | toNative = believe_me 17 | toForeign = believe_me 18 | 19 | implementation Mapping (Boxed Double) Double where 20 | toNative = believe_me 21 | toForeign = believe_me 22 | 23 | implementation Mapping (Boxed Integer) Integer where 24 | toNative = believe_me 25 | toForeign = believe_me 26 | 27 | implementation Mapping (Boxed Unit) Unit where 28 | toNative = believe_me 29 | toForeign = believe_me 30 | 31 | implementation Mapping (Boxed Char) Char where 32 | toNative = believe_me 33 | toForeign = believe_me 34 | 35 | implementation Mapping (FList t) (List (Boxed t)) where 36 | toNative a = believe_me . unsafePerformIO $ fcall1 "flist_to_native" $ believe_me a 37 | toForeign b = believe_me . unsafePerformIO $ fcall1 "list_to_foreign" $ believe_me b 38 | 39 | implementation Mapping (FVect n t) (Vect n (Boxed t)) where 40 | toNative {n} a = believe_me . unsafePerformIO $ 41 | let sig = Integer -> FVect n t -> FFI.IO Ptr in 42 | let n = believe_me . the Integer $ fromNat n in 43 | fcall2 "fvect_to_native" n $ believe_me a 44 | 45 | toForeign {n} b = believe_me . unsafePerformIO $ 46 | let sig = Integer -> Ptr -> FFI.IO (FVect n t) in 47 | let n = believe_me . the Integer $ fromNat n in 48 | fcall2 "vect_to_foreign" n $ believe_me b 49 | 50 | mapTypes : Vect n Type -> Vect n Type 51 | mapTypes ts = map Boxed ts 52 | 53 | implementation Mapping (FHVect xs) (HVect (mapTypes xs)) where 54 | toNative {xs} a = believe_me . unsafePerformIO $ 55 | let sig = Integer -> FHVect xs -> FFI.IO Ptr in 56 | let n = believe_me . the Integer . fromNat $ size xs in 57 | fcall2 "fhvect_to_native" n $ believe_me a 58 | toForeign {xs} b = believe_me . unsafePerformIO $ 59 | let sig = Integer -> Ptr -> FFI.IO (FHVect xs) in 60 | let n = believe_me . the Integer . fromNat $ size xs in 61 | fcall2 "hvect_to_foreign" n $ believe_me b 62 | 63 | implementation Mapping (Boxed String) String where 64 | toNative a = believe_me . unsafePerformIO $ fcall1 "fstr_to_native" $ believe_me a 65 | toForeign b = believe_me . unsafePerformIO $ fcall1 "str_to_foreign" $ believe_me b 66 | 67 | implementation Show (FList t) where 68 | show = toNative . toText 69 | 70 | implementation Show (FVect n t) where 71 | show = toNative . toText 72 | 73 | implementation Show (FHVect xs) where 74 | show = toNative . toText 75 | 76 | public export 77 | data FModuleSpec : String -> Type where 78 | TheModule : (s : String) -> FModuleSpec s 79 | 80 | ||| foreign module 81 | public export 82 | FModule : String -> Type 83 | FModule s = Boxed (FModuleSpec s) 84 | 85 | %inline 86 | camImport : FModuleSpec s -> FFI.IO (FModule s) 87 | camImport {s} _ = believe_me $ fcall1 "get_module" $ believe_me s 88 | 89 | %inline 90 | camImportFrom : FModule mod_name -> String -> FFI.IO Unsafe 91 | camImportFrom {mod_name} m str = 92 | let fieldname = believe_me $ the (Boxed String) $ toForeign str in 93 | fcall2 "module_property" (believe_me m) fieldname 94 | 95 | %inline 96 | unsafe : a -> Unsafe 97 | unsafe a = unsafePerformIO $ fcall1 "identity" (believe_me a) 98 | 99 | %inline 100 | unsafeCall : Unsafe -> Unsafe -> FFI.IO Unsafe 101 | unsafeCall f args = fcall2 "unsafe_call" f args 102 | 103 | 104 | 105 | implicit iList2FList : List (Boxed a) -> FList a 106 | iList2FList = toForeign 107 | 108 | implicit iVect2FVect : Vect n (Boxed a) -> FVect n a 109 | iVect2FVect = toForeign 110 | 111 | implicit iHVect2FHVect : {xs1: Vect n Type} -> HVect (map Boxed xs1) -> FHVect xs1 112 | iHVect2FHVect = toForeign 113 | 114 | implicit iString2Text : String -> Boxed String 115 | iString2Text = toForeign 116 | 117 | implicit iFList2List : FList a -> List (Boxed a) 118 | iFList2List = toNative 119 | 120 | implicit iFVect2Vect : FVect n a -> Vect n (Boxed a) 121 | iFVect2Vect = toNative 122 | 123 | implicit iFHVect2HVect : {xs1: Vect n Type} -> FHVect xs1 -> HVect (map Boxed xs1) 124 | iFHVect2HVect = toNative 125 | 126 | implicit iText2String : Boxed String -> String 127 | iText2String = toNative 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /libs/Cam/Data/FCollections.idr: -------------------------------------------------------------------------------- 1 | {- 2 | Foreign collections 3 | - FList : foreign List 4 | - FVect : foreign Vector 5 | - FHVect : foreign Heterogeneous Vector 6 | 7 | If your language supports some of them, just make sure 8 | the relatedc builtins functions should be implemented in 9 | your language, like 10 | python: `cam-python/idris_cam/rumtime.py' 11 | julia: `cam-julia/src/Runtime.jl` 12 | -} 13 | 14 | module FCollections 15 | import Data.Vect 16 | import Data.HVect 17 | import Cam.Data.Collections 18 | import Cam.FFI 19 | import Cam.IO 20 | 21 | %access public export 22 | %hide Vect.index 23 | %hide HVect.index 24 | 25 | -- maybe overflow 26 | %inline 27 | indexRawOF : String -> Int -> Unsafe -> Unsafe 28 | indexRawOF s i v = let builtin = Builtin s in 29 | let i = believe_me i in 30 | let box = fcall FFun2 builtin i v in 31 | believe_me $ unsafePerformIO box 32 | 33 | %inline 34 | indexRaw : String -> Integer -> Unsafe -> Unsafe 35 | indexRaw s i v = let builtin = Builtin s in 36 | let i = believe_me i in 37 | let box = fcall FFun2 builtin i v in 38 | believe_me $ unsafePerformIO box 39 | 40 | 41 | -- using `nat` data structure to index 42 | %inline 43 | indexRawNat : String -> Nat -> Unsafe -> Unsafe 44 | indexRawNat s i v = let builtin = Builtin s in 45 | let i = believe_me i in 46 | let box = fcall FFun2 builtin i v in 47 | believe_me $ unsafePerformIO box 48 | 49 | -- Implementations for FList 50 | %inline 51 | sizeFList : FList a -> Integer 52 | sizeFList lst = assert_total $ 53 | let builtin = Builtin "size_flist" in 54 | let box = fcall FFun1 builtin (believe_me lst) in 55 | believe_me $ unsafePerformIO box 56 | 57 | implementation Sized (FList t) where 58 | -- It seems that using `size = sizeFlist` causes bad properties, not sure yet 59 | size lst = fromInteger $ sizeFList lst 60 | 61 | implementation Indexable (FList t) Integer where 62 | eltype {t} _ _ = Boxed t 63 | index {t} i xs = believe_me e 64 | where 65 | src : Unsafe 66 | src = believe_me xs 67 | e : Unsafe 68 | e = indexRaw "index_flist" i src 69 | 70 | 71 | reverseFList : FList a -> FList a 72 | reverseFList lst = let builtin = Builtin "reverse_flist" in 73 | let box = fcall FFun1 builtin (believe_me lst) in 74 | believe_me $ unsafePerformIO box 75 | 76 | implementation Reversable (FList a) (FList a) where 77 | reverse = reverseFList 78 | 79 | -- Implementations for FVect 80 | 81 | sizeFVect : FVect n a -> Nat 82 | sizeFVect {n} _ = n 83 | 84 | implementation StaticSized (FVect n a) where 85 | typeSize {n} _ = n 86 | 87 | implementation Sized (FVect n a) where 88 | size vec = sizeFVect vec 89 | 90 | implementation Indexable (FVect n t) (Fin n) where 91 | eltype {t} _ _ = Boxed t 92 | index fin vec = believe_me e 93 | where 94 | i : Integer 95 | i = finToInteger fin 96 | src : Unsafe 97 | src = believe_me vec 98 | e : Unsafe 99 | e = indexRaw "index_fvect" i src 100 | 101 | reverseFVect : FVect n a -> FVect n a 102 | reverseFVect {n} vec = let builtin = Builtin "reverse_fvect" in 103 | let box = fcall FFun1 builtin $ believe_me vec in 104 | believe_me $ unsafePerformIO box 105 | 106 | implementation Reversable (FVect n a) (FVect n a) where 107 | reverse vec = reverseFVect vec 108 | 109 | 110 | -- Implementations for FHVect 111 | 112 | sizeFHVect : {xs: Vect n Type} -> FHVect xs -> Nat 113 | sizeFHVect {n} _ = n 114 | 115 | implementation StaticSized (FHVect xs) where 116 | typeSize {xs} _ = size xs 117 | 118 | implementation Sized (FHVect xs) where 119 | size vec = sizeFHVect vec 120 | 121 | 122 | -- It's tricky here for there're still some bugs in Idris. 123 | -- related: https://github.com/idris-lang/Idris-dev/issues/3136 124 | 125 | 126 | implementation Indexable (FHVect xs) (Fin (size xs)) where 127 | eltype {xs} fin _ = Boxed (index fin xs) 128 | index fin vec = believe_me e 129 | where 130 | i : Integer 131 | i = finToInteger fin 132 | src : Unsafe 133 | src = believe_me vec 134 | e : Unsafe 135 | e = indexRaw "index_fhvect" i src 136 | 137 | reverseFHVect : FHVect xs -> FHVect (reverseVect xs) 138 | reverseFHVect {xs} vec = let builtin = Builtin "reverse_fvect" in 139 | let box = fcall FFun1 builtin $ believe_me vec in 140 | believe_me $ unsafePerformIO box 141 | 142 | implementation Reversable (FHVect xs) (FHVect (reverseVect xs)) where 143 | reverse vec = reverseFHVect vec 144 | -------------------------------------------------------------------------------- /libs/Cam/FFI.idr: -------------------------------------------------------------------------------- 1 | module FFI 2 | import Data.HVect 3 | import Data.Vect 4 | 5 | %hide IO 6 | %access public export 7 | 8 | 9 | data UnsafeRaw; 10 | data Boxed t = MkBoxed t 11 | 12 | Unsafe : Type 13 | Unsafe = Boxed UnsafeRaw 14 | 15 | mutual 16 | 17 | data FList : Type -> Type where 18 | MockFList : (t: Type) -> FList t 19 | 20 | -- sized vector 21 | data FVect : Nat -> Type -> Type where 22 | MockFVect : (n: Nat) -> (t: Type) -> FVect n t 23 | 24 | -- Heterogeneous Vector. 25 | -- In many language, it's called `tuple`. 26 | data FHVect : Vect n Type -> Type where 27 | MockFHVect : (xs: Vect n Type) -> FHVect xs 28 | 29 | data CamTypes : Type -> Type where 30 | Cam_Unsafe : CamTypes Unsafe 31 | 32 | data ForeignName 33 | = Builtin String 34 | | Library String String 35 | | BuiltinVar String 36 | | LibraryVar String String 37 | 38 | FFICam : FFI 39 | FFICam = MkFFI CamTypes ForeignName String 40 | 41 | public export 42 | IO : Type -> Type 43 | IO = IO' FFICam 44 | 45 | FFun0 : Type 46 | FFun0 = IO Unsafe 47 | 48 | FFun1 : Type 49 | FFun1 = Unsafe -> IO Unsafe 50 | 51 | FFun2 : Type 52 | FFun2 = Unsafe -> Unsafe -> IO Unsafe 53 | 54 | FFun3 : Type 55 | FFun3 = Unsafe -> Unsafe -> Unsafe -> IO Unsafe 56 | 57 | ||| call foreign language apis 58 | %inline 59 | fcall: (ty : Type) -> (fname : ForeignName) -> {auto fty : FTy FFICam [] ty} -> ty 60 | fcall ty fname = foreign FFICam fname ty 61 | 62 | %inline 63 | fvar : String -> IO Unsafe 64 | fvar n = fcall (IO Unsafe) (BuiltinVar n) 65 | 66 | %inline 67 | fcall0 : String -> IO Unsafe 68 | fcall0 n = fcall FFun0 (Builtin n) 69 | 70 | %inline 71 | fcall1 : String -> Unsafe -> IO Unsafe 72 | fcall1 n src = fcall FFun1 (Builtin n) src 73 | 74 | %inline 75 | fcall2 : String -> Unsafe -> Unsafe -> IO Unsafe 76 | fcall2 n src1 src2 = fcall FFun2 (Builtin n) src1 src2 77 | 78 | %inline 79 | fcall3 : String -> Unsafe -> Unsafe -> Unsafe -> IO Unsafe 80 | fcall3 n src1 src2 src3 = fcall FFun3 (Builtin n) src1 src2 src3 81 | 82 | %inline 83 | fassert: a -> b -> IO () 84 | fassert a b = 85 | let a = believe_me a in 86 | let b = believe_me b in 87 | believe_me $ fcall FFun2 (Builtin "cam-assert") a b 88 | -------------------------------------------------------------------------------- /libs/Cam/IO.idr: -------------------------------------------------------------------------------- 1 | module IO 2 | import Cam.FFI 3 | 4 | ||| print native(idris side) object 5 | public export 6 | %inline 7 | println : a -> IO () 8 | println s = believe_me $ fcall FFun1 (Builtin "println") $ believe_me s 9 | 10 | ||| print any foreign object 11 | public export 12 | %inline 13 | fprintln : Boxed a -> IO () 14 | fprintln boxed = believe_me $ fcall FFun1 (Builtin "println") $ believe_me boxed 15 | 16 | ||| print any object 17 | public export 18 | %inline 19 | putStrLn : String -> IO () 20 | putStrLn boxed = believe_me $ fcall FFun1 (Builtin "println") $ believe_me boxed 21 | 22 | 23 | public export 24 | %inline 25 | toText : a -> Boxed String 26 | toText a = believe_me . unsafePerformIO $ fcall FFun1 (Builtin "to_text") $ believe_me a 27 | -------------------------------------------------------------------------------- /libs/Cam/OS/FileSystem.idr: -------------------------------------------------------------------------------- 1 | module Cam.FileSystem 2 | import Cam.FFI 3 | import Cam.Data.FCollections 4 | import Cam.Data.Compat 5 | import Data.Vect 6 | import Data.HVect 7 | 8 | %access export 9 | public export 10 | %inline 11 | 12 | pipe : () -> FHVect [Int, Int] 13 | pipe () = believe_me . unsafePerformIO $ fcall1 "filesystem_pipe" $ believe_me () 14 | 15 | public export 16 | %inline 17 | getcwd : () -> Boxed String 18 | getcwd () = believe_me . unsafePerformIO $ fcall1 "filesystem_getcwd" $ believe_me () 19 | 20 | data FileHandlerSpec; 21 | 22 | public export 23 | FileHandler : Type 24 | FileHandler = Boxed FileHandlerSpec 25 | 26 | public export 27 | %inline 28 | openFile : (filename: String) -> (mode: String) -> IO FileHandler 29 | openFile filename mode = 30 | let filename = believe_me . the (Boxed String) $ toForeign filename in 31 | let mode = believe_me . the (Boxed String) $ toForeign mode in 32 | believe_me $ fcall2 "filesystem_open_file" filename mode 33 | 34 | public export 35 | %inline 36 | closeFile : FileHandler -> IO () 37 | closeFile f = 38 | let f = believe_me f in 39 | believe_me $ fcall1 "filesystem_close_file" f 40 | 41 | public export 42 | %inline 43 | readAllText : FileHandler -> IO (Boxed String) 44 | readAllText f = 45 | let f = believe_me f in 46 | believe_me $ fcall1 "filesystem_read_all_text" f 47 | -------------------------------------------------------------------------------- /libs/Cam/OS/Platform.idr: -------------------------------------------------------------------------------- 1 | module Cam.Platform 2 | import Cam.FFI 3 | 4 | public export 5 | %inline 6 | platformName : () -> Boxed String 7 | platformName () = believe_me . unsafePerformIO $ fcall1 "platform_name" (believe_me ()) 8 | 9 | public export 10 | %inline 11 | platformSystem : () -> Boxed String 12 | platformSystem () = believe_me . unsafePerformIO $ fcall1 "platform_system" (believe_me ()) 13 | -------------------------------------------------------------------------------- /libs/Test/Simple.idr: -------------------------------------------------------------------------------- 1 | module Test.Simple 2 | import Cam.FFI 3 | import Cam.OS.FileSystem 4 | import Cam.IO 5 | import Cam.Data.Collections 6 | import Cam.Data.FCollections 7 | import Cam.Data.Compat 8 | import Data.Vect 9 | import Data.HVect 10 | 11 | %hide HVect.index 12 | %hide Vect.index 13 | %hide Vect.reverse 14 | 15 | %access export 16 | 17 | f : StaticSized c => TypeHolder c -> Nat 18 | f d = typeSize d 19 | 20 | testSimple : FFI.IO () 21 | testSimple = do 22 | mlstyle <- camImport $ TheModule "MLStyle" 23 | fprintln mlstyle -- fprintln works for only foreign objects 24 | gen_match <- camImportFrom mlstyle "gen_match" 25 | println gen_match -- println works for all objects 26 | file <- openFile "./text.txt" "r" 27 | text <- readAllText file 28 | closeFile file 29 | fprintln $ text 30 | println $ show hvec2 31 | putStrLn $ show a -- putStrLn works for only String 32 | println $ show reva 33 | println $ show e 34 | println $ show hvec 35 | println $ show hvecItem 36 | println $ "test flist reverse :" ++ show flist_rev 37 | println $ "test flist to list :" ++ show lst2 38 | println $ "test fhvect:" ++ show fhvect 39 | where 40 | lst : List(Boxed Integer) 41 | lst = map toForeign [1, 2, 3] 42 | 43 | a : Vect 3 Int 44 | a = [1, 2, 3] 45 | nnn : Nat 46 | nnn = f (MkTypeHolder (Vect 3 Int)) 47 | 48 | reva : Vect 3 Int 49 | reva = reverse a 50 | 51 | e : Int 52 | e = index (the (Fin _) $ fromInteger 1) a 53 | 54 | hvec : HVect [Int, Double] 55 | hvec = [1, 2.0] 56 | 57 | hvecItem : Double 58 | hvecItem = index (the (Fin _) $ fromInteger 1) hvec 59 | 60 | hvec2 : HVect [Double, Int] 61 | hvec2 = reverse hvec 62 | 63 | flist : FList Integer 64 | flist = toForeign lst 65 | 66 | lst2 : List Integer 67 | lst2 = map toNative (toNative flist) 68 | 69 | flist_item : Boxed Integer 70 | flist_item = index 2 flist 71 | 72 | flist_rev: FList Integer 73 | flist_rev = reverse flist 74 | 75 | flist_size: Nat 76 | flist_size = size flist 77 | 78 | toFI : Integer -> Boxed Int 79 | toFI = toForeign . the Int . fromInteger 80 | 81 | fvect: FVect 2 Int 82 | fvect = toForeign (with Vect [toFI 1, toFI 3]) 83 | 84 | fvect_item : Boxed Int 85 | fvect_item = index (the (Fin _) $ fromInteger 1) fvect 86 | 87 | fvect_rev: FVect 2 Int 88 | fvect_rev = reverse fvect 89 | 90 | fhvect : FHVect [String, Int] 91 | fhvect = toForeign $ the (HVect _) [toForeign "1", toFI 3] 92 | 93 | fhvect_item : Boxed String 94 | fhvect_item = index (the (Fin _) $ fromInteger 0) fhvect 95 | 96 | fhvect_rev: FHVect [Int, String] 97 | fhvect_rev = reverse fhvect 98 | 99 | hvect_f : HVect [Boxed Int, Boxed String] 100 | hvect_f = toNative fhvect_rev 101 | -------------------------------------------------------------------------------- /libs/cam.ipkg: -------------------------------------------------------------------------------- 1 | package cam 2 | 3 | modules = Cam.FFI 4 | , Cam.IO 5 | , Cam.Data.Collections 6 | , Cam.Data.FCollections 7 | , Cam.Data.Compat 8 | , Cam.OS.Platform 9 | , Cam.OS.FileSystem 10 | , Test.Simple 11 | 12 | tests = Test.Simple.testSimple 13 | -------------------------------------------------------------------------------- /libs/clean_ibc.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | from os import remove 3 | 4 | 5 | p = Path(".") 6 | def clean(p): 7 | for each in p.iterdir(): 8 | each: Path 9 | if each.is_dir(): 10 | clean(each) 11 | elif each.suffix == '.ibc': 12 | remove(str(each)) 13 | clean(p) 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /libs/gen_test.py: -------------------------------------------------------------------------------- 1 | from subprocess import check_call, PIPE, Popen 2 | import re 3 | 4 | julia = r"""using CamJulia 5 | using MLStyle 6 | 7 | rmlines = @λ begin 8 | Expr(head, args...) -> Expr(head, filter(x -> x !== nothing, map(rmlines, args))...) 9 | ::LineNumberNode -> nothing 10 | a -> a 11 | end 12 | 13 | macro load_cam(path) 14 | aeson = CamJulia.ReadIR.load_aeson(path); 15 | ir = CamJulia.ReadIR.aeson_to_ir(aeson) 16 | x = CamJulia.CAM.ir_to_julia(ir) 17 | # @info rmlines(x) 18 | esc(x) 19 | end 20 | 21 | # @load_cam "./test.cam" 22 | @load_cam "{}" 23 | """ 24 | 25 | python = r"""import sys 26 | import os 27 | import json 28 | import unittest 29 | sys.path.append('..') 30 | 31 | from idris_cam.read_ir import * 32 | 33 | def load_cam(path, session): 34 | with open(path, 'r') as f: 35 | js = json.load(f) 36 | 37 | letrec: LetRec = aeson_to_ir(js) 38 | return run_code(letrec, session) 39 | 40 | class Test(unittest.TestCase): 41 | def test_too_known(self): 42 | sess = LinkSession() 43 | # load_cam('./test.cam', sess) 44 | load_cam({}, sess) 45 | unittest.main() 46 | """ 47 | 48 | def load_cam_and_test(path): 49 | with open('../cam-julia/test/runtests.jl', 'w') as f: 50 | f.write(julia.format(path.strip())) 51 | 52 | get_exe = re.compile(r"Uncaught error\:(?P[\s\S]+)\: rawSystem").search 53 | 54 | a = Popen(['stack', 'exec', 'idris', '--', '--checkpkg=cam.ipkg'], stdout=PIPE, stderr=PIPE) 55 | print(a.stderr.read().decode()) 56 | 57 | a = Popen(['stack', 'exec', 'idris', '--', '--testpkg=cam.ipkg', '--codegen=cam'], stderr=PIPE, stdout=PIPE) 58 | 59 | a.wait() 60 | err_msg = a.stdout.read().decode() 61 | x = get_exe(err_msg).group('exe') 62 | load_cam_and_test(x) 63 | -------------------------------------------------------------------------------- /libs/test.idr: -------------------------------------------------------------------------------- 1 | module Main 2 | import Data.Vect 3 | %hide natToFin 4 | %hide cmp 5 | %hide index 6 | %default total 7 | 8 | public export 9 | interface Indexable c i where 10 | eltype : Type 11 | index' : i -> c -> eltype 12 | 13 | implementation Indexable (Vect k t) (Fin k) where 14 | eltype = t 15 | index' FZ (x :: xs) = x 16 | index' (FS k) (x :: xs) = index' k xs 17 | 18 | int_vec : Vect 2 Int 19 | int_vec = [2, 3] 20 | 21 | cmp : Nat -> Nat -> Ordering 22 | cmp Z Z = EQ 23 | cmp Z _ = LT 24 | cmp _ Z = GT 25 | cmp (S k1) (S k2) = cmp k1 k2 26 | 27 | -- -> {auto p: cmp m n = LT} 28 | 29 | filter' : (a -> Bool) -> Vect n a -> (p ** Vect p a) 30 | filter' p [] = ( 0 ** [] ) 31 | filter' p (x :: xs) with (filter' p xs) 32 | | ( a ** xs' ) = if (p x) then ( (S a) ** x :: xs' ) else ( a ** xs' ) 33 | 34 | -- fin : {n : Nat} -> (m: Nat) -> {default 0 p: Nat} -> Fin n 35 | -- fin {n = S k} Z {p = 0}= FZ 36 | -- fin {n = S k2} (S k1) = FS (fin {n = k2} k1) 37 | -- fin {n=Z} m {p=(S _, Z)} impossible 38 | 39 | -- z : Int 40 | -- z = index' (fin 1) int_vec 41 | 42 | -- main : IO () 43 | -- main = putStrLn . show $ z 44 | -------------------------------------------------------------------------------- /src/IRTS/CodegenCam.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE LambdaCase #-} 2 | {-# LANGUAGE DeriveGeneric #-} 3 | {-# LANGUAGE ViewPatterns #-} 4 | 5 | module IRTS.CodegenCam(codegenCam) where 6 | import Data.Map.Strict (Map) 7 | import Prelude hiding (writeFile) 8 | import qualified Data.Map.Strict as Map 9 | 10 | import Idris.Core.TT 11 | import IRTS.Lang 12 | import IRTS.Defunctionalise 13 | import IRTS.CodegenCommon 14 | import Data.Aeson.Text (encodeToLazyText) 15 | import Data.Text.Lazy.IO (writeFile) 16 | import Data.Aeson 17 | 18 | import GHC.Generics 19 | import Control.Arrow 20 | 21 | vars = fmap (\x -> "var." ++ show x) [0 ..] 22 | 23 | data ComIR 24 | = ComLet String ComIR ComIR 25 | | ComLetrec [(String, ComIR)] ComIR 26 | | ComIf ComIR ComIR ComIR 27 | | ComWhile ComIR ComIR 28 | | ComMutate String ComIR 29 | | ComFun [String] ComIR 30 | | ComApp ComIR [ComIR] 31 | | ComVar String 32 | | ComBlock [ComIR] 33 | | ComTuple [ComIR] 34 | | ComProj ComIR ComIR 35 | 36 | | ComSymbol String -- implement fast data types 37 | | ComBigInt Integer 38 | | ComInt Int 39 | | ComDouble Double 40 | | ComStr String 41 | | ComCh Char 42 | | ComBool Bool 43 | | ComNil 44 | | ComInternal String 45 | deriving (Show, Eq, Ord, Generic) 46 | 47 | instance ToJSON ComIR where 48 | toEncoding = genericToEncoding defaultOptions 49 | 50 | asThunk :: ComIR -> ComIR 51 | asThunk = ComFun [] 52 | 53 | codegenCam :: CodeGenerator 54 | codegenCam ci = 55 | writeFile filename (encodeToLazyText . toJSON $ ir) 56 | where 57 | filename = outputFile ci 58 | ir = mkDecls . fmap snd $ defunDecls ci 59 | t = map (showCG . fst) . simpleDecls $ ci 60 | 61 | specify (showCG -> "MkUnit") = ComNil 62 | specify (showCG -> "Prelude.Bool.True") = ComBool True 63 | specify (showCG -> "Prelude.Bool.False") = ComBool False 64 | specify (showCG -> a) = ComSymbol a 65 | 66 | decl :: DDecl -> (String, ComIR) 67 | decl (DFun n ns body) = 68 | (showCG n, ComFun (fmap showCG ns) $ toIR body) 69 | decl (DConstructor n tag arity) = 70 | (showCG n, ComFun argnames dataComposition) 71 | where 72 | argnames = take arity vars 73 | dataComposition = 74 | if null argnames 75 | then specify n 76 | else ComTuple (ComSymbol (showCG n) : fmap ComVar argnames) 77 | 78 | mkDecls :: [DDecl] -> ComIR -- top level let recs 79 | mkDecls xs = 80 | ComLetrec (fmap decl xs) (ComApp (toIR $ sMN 0 "runMain") []) 81 | 82 | camErr = ComInternal "cam-rt.err" 83 | camCmp = ComInternal "cam-rt.cmp" 84 | camIs = ComInternal "cam-rt.is" 85 | 86 | class HasIR a where 87 | toIR :: a -> ComIR 88 | 89 | instance HasIR Name where 90 | toIR = ComVar . showCG 91 | 92 | instance HasIR Const where 93 | toIR = \case 94 | I i -> ComInt i 95 | Fl d -> ComDouble d 96 | Ch c -> ComCh c 97 | Str s -> ComStr s 98 | BI i -> ComBigInt i 99 | a -> error $ "not impl: " ++ show a 100 | 101 | instance HasIR DExp where 102 | toIR = \case 103 | DV name -> toIR name 104 | DApp _ name args -> ComApp (toIR name) $ fmap toIR args 105 | DLet name v body -> ComLet (showCG name) (toIR v) (toIR body) 106 | DUpdate name body -> ComMutate (showCG name) (toIR body) 107 | DC _ i name [] -> specify name 108 | DC _ i name args -> ComTuple $ ComSymbol (showCG name) : fmap toIR args 109 | DCase _ var' alts -> patternMatchComp var' alts 110 | -- temporarily I treat SChkCase as SCase, for I don't know their diffs accurately. 111 | DChkCase var' alts -> patternMatchComp var' alts 112 | DProj var i -> ComProj (toIR var) (ComInt i) 113 | DConst const -> toIR const 114 | DForeign retTy fname xs -> 115 | let args = fmap (toIR . snd) xs in 116 | case fname of 117 | FApp n [FStr name] | show n == "BuiltinVar"-> 118 | if null xs then 119 | ComInternal $ "builtin-" ++ name 120 | else errorWithoutStackTrace "Accessing foreign variables requires no function arguments." 121 | FApp n [FStr name] | show n == "Builtin" -> 122 | let f = ComInternal $ "builtin-" ++ name 123 | in ComApp f args 124 | FApp n [FStr mod, FStr name] | show n == "LibraryVar"-> 125 | if null xs then 126 | ComInternal $ mod ++ "-" ++ name 127 | else errorWithoutStackTrace "Accessing foreign variables requires no function arguments." 128 | FApp n [FStr mod, FStr name] | show n == "Library" -> 129 | let f = ComInternal $ mod ++ "-" ++ name 130 | in ComApp f args 131 | op -> errorWithoutStackTrace $ "Not supported FFI ops :" ++ show op 132 | 133 | DOp primfn vars -> ComApp (toIR primfn) $ fmap toIR vars 134 | DNothing -> ComNil -- will never be inspected 135 | DError s -> ComApp camErr [ComStr s] 136 | 137 | 138 | patternMatchComp var' cs = recur cs where 139 | var = toIR var' 140 | recur [] = ComApp camErr [ComStr $ "unsolved case for " ++ show var' ++ " : " ++ show cs] 141 | recur (x:xs) = 142 | let tail = recur xs 143 | in case x of 144 | DConCase _ n ns body 145 | | null ns -> 146 | let cond = ComApp camIs [specify n, var] 147 | in ComIf cond (toIR body) tail 148 | | otherwise -> 149 | let capturing = foldr reducer (toIR body) (zip ns [1 ..]) 150 | casename = showCG n 151 | reducer (n, i) = ComLet (showCG n) (ComProj var $ ComInt i) 152 | cond = ComApp camIs [ComSymbol casename, ComProj var $ ComInt 0] 153 | in ComIf cond capturing tail 154 | DConstCase const body -> 155 | ComIf (ComApp camCmp [var, toIR const]) (toIR body) tail 156 | DDefaultCase body -> toIR body 157 | 158 | instance HasIR PrimFn where 159 | toIR = \case 160 | LPlus _ -> ComInternal "prim-plus" 161 | LMinus _ -> ComInternal "prim-minus" 162 | LTimes _ -> ComInternal "prim-times" 163 | LUDiv _ -> ComInternal "prim-udiv" 164 | LSDiv _ -> ComInternal "prim-sdiv" 165 | LURem _ -> ComInternal "prim-urem" 166 | LSRem _ -> ComInternal "prim-srem" 167 | LAnd _ -> ComInternal "prim-and" 168 | LOr _ -> ComInternal "prim-or" 169 | LXOr _ -> ComInternal "prim-xor" 170 | LCompl _ -> ComInternal "prim-compl" 171 | LSHL _ -> ComInternal "prim-shl" 172 | LLSHR _ -> ComInternal "prim-lshr" 173 | LASHR _ -> ComInternal "prim-ashr" 174 | LEq _ -> ComInternal "prim-eq" 175 | LLt _ -> ComInternal "prim-lt" 176 | LLe _ -> ComInternal "prim-le" 177 | LGt _ -> ComInternal "prim-gt" 178 | LGe _ -> ComInternal "prim-ge" 179 | LSLt _ -> ComInternal "prim-slt" 180 | LSLe _ -> ComInternal "prim-sle" 181 | LSGt _ -> ComInternal "prim-sgt" 182 | LSGe _ -> ComInternal "prim-sge" 183 | LSExt _ _ -> ComInternal "prim-sext" 184 | LZExt _ _ -> ComInternal "prim-zext" 185 | LTrunc _ _ -> ComInternal "prim-trunc" 186 | LStrConcat -> ComInternal "prim-strconcat" 187 | LStrLt -> ComInternal "prim-strlt" 188 | LStrEq -> ComInternal "prim-streq" 189 | LStrLen -> ComInternal "prim-strlen" 190 | LIntFloat _ -> ComInternal "prim-intfloat" 191 | LFloatInt _ -> ComInternal "prim-floatint" 192 | LIntStr _ -> ComInternal "prim-intstr" 193 | LStrInt _ -> ComInternal "prim-strint" 194 | LFloatStr -> ComInternal "prim-floatstr" 195 | LStrFloat -> ComInternal "prim-strfloat" 196 | LChInt _ -> ComInternal "prim-chint" 197 | LIntCh _ -> ComInternal "prim-intch" 198 | LBitCast _ _ -> ComInternal "prim-bitcast" 199 | LFExp -> ComInternal "prim-fexp" 200 | LFLog -> ComInternal "prim-flog" 201 | LFSin -> ComInternal "prim-fsin" 202 | LFCos -> ComInternal "prim-fcos" 203 | LFTan -> ComInternal "prim-ftan" 204 | LFASin -> ComInternal "prim-fasin" 205 | LFACos -> ComInternal "prim-facos" 206 | LFATan -> ComInternal "prim-fatan" 207 | LFATan2 -> ComInternal "prim-fatan2" 208 | LFSqrt -> ComInternal "prim-fsqrt" 209 | LFFloor -> ComInternal "prim-ffloor" 210 | LFCeil -> ComInternal "prim-fceil" 211 | LFNegate -> ComInternal "prim-fnegate" 212 | LStrHead -> ComInternal "prim-strhead" 213 | LStrTail -> ComInternal "prim-strtail" 214 | LStrCons -> ComInternal "prim-strcons" 215 | LStrIndex -> ComInternal "prim-strindex" 216 | LStrRev -> ComInternal "prim-strrev" 217 | LStrSubstr -> ComInternal "prim-strsubstr" 218 | LReadStr -> ComInternal "prim-readstr" 219 | LWriteStr -> ComInternal "prim-writestr" 220 | LSystemInfo -> ComInternal "prim-systeminfo" 221 | LFork -> ComInternal "prim-fork" 222 | LPar -> ComInternal "prim-par" 223 | LExternal _ -> ComInternal "prim-external" 224 | LCrash -> ComInternal "prim-crash" 225 | LNoOp -> ComInternal "prim-noop" 226 | -------------------------------------------------------------------------------- /src/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | import Idris.AbsSyntax 3 | import Idris.Core.TT 4 | import Idris.ElabDecls 5 | import Idris.Main 6 | import Idris.ModeCommon 7 | import Idris.REPL 8 | import Idris.Options 9 | import IRTS.Simplified 10 | 11 | import IRTS.Compiler 12 | import IRTS.CodegenCam 13 | import IRTS.CodegenCommon 14 | 15 | import System.Environment 16 | import System.Exit 17 | import Control.Monad 18 | 19 | import Paths_idris_cam 20 | 21 | data Opts = Opts { inputs :: [FilePath], 22 | output :: FilePath } 23 | 24 | showUsage = do putStrLn "A code generator which is intended to be called by the compiler, not by a user." 25 | putStrLn "Usage: idris-codegen-cam [-o ]" 26 | exitSuccess 27 | 28 | getOpts :: IO Opts 29 | getOpts = process (Opts [] "a.out") <$> getArgs 30 | where 31 | process opts ("-o":o:xs) = process (opts { output = o }) xs 32 | process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs 33 | process opts [] = opts 34 | 35 | cMain :: Opts -> Idris () 36 | cMain opts = do elabPrims 37 | loadInputs (inputs opts) Nothing 38 | mainProg <- fmap Just elabMain 39 | ir <- compile (Via IBCFormat "cam") (output opts) mainProg 40 | -- runIO $ forM_ (fmap (show . snd) (defunDecls ir)) putStrLn 41 | runIO $ codegenCam ir 42 | 43 | main :: IO () 44 | main = do opts <- getOpts 45 | if null (inputs opts) 46 | then showUsage 47 | else runMain (cMain opts) -------------------------------------------------------------------------------- /stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-13.17 2 | 3 | packages: 4 | - . 5 | 6 | # for unix: 7 | # extra-deps: 8 | # - idris-1.3.1@sha256:8586191c8722199c608b86a44cbf6571875fd425a0041e798ecc100d2e9537fc 9 | # - Cabal-2.2.0.1@sha256:2a80d8fb655474f0eaeb20434c47f64f84e6302e55973056f00df8ca050b9683 10 | # - aeson-1.3.1.1@sha256:1ab29743b4c4c9be7df57200ed2c8779048adda4cead075944b7b471e93ed4c3 11 | # - code-page-0.1.3@sha256:9e13dee5c6d23e570f72cb376e7996ffcd9728c4a6daa60f05f2f2c204296eec 12 | # - containers-0.5.11.0@sha256:28ad7337057442f75bc689315ab4ec7bdf5e6b2c39668f306672cecd82c02798 13 | # - megaparsec-6.5.0@sha256:a1dfed92863607ea9f7609a0578d486761a052a4d01aaff95b90f25da2564346 14 | # - network-2.7.0.2@sha256:7cb8d7bc2080be946cf87890c807b12dae9c59314fa030b2687999100ce60512 15 | # - zip-archive-0.3.3@sha256:53f871653059f87285f434319598f380d986cd7fd9219de555dcafc496121a7c 16 | 17 | # for windows 18 | extra-deps: 19 | - idris-1.3.2@sha256:4d503ff5d51131c18b677aa75776d69c031f9a6391ae531dd0623dbf9db01556,13508 20 | - directory-1.3.6.0@sha256:d3d89c752f99e78f3e1d11c74696d2ba78b199f47c89e92934003deb84cb3ff9,2810 21 | - process-1.6.7.0@sha256:305bcf44c42a96425e77af1748183f505a701648f68cc299d5ad8ac1b866a6a1,2468 22 | - time-1.8.0.4@sha256:3f6eddf238b828eb4f82683acce1c3afe64784f0d20114239b738c123316c85c,5494 23 | - Win32-2.6.2.0@sha256:515518df0728294c99822c65b04be10a242933f40240b125c23469f45c8b11da,4227 -------------------------------------------------------------------------------- /test/Spec.hs: -------------------------------------------------------------------------------- 1 | main :: IO () 2 | main = putStrLn "Test suite not yet implemented" 3 | -------------------------------------------------------------------------------- /tools/prim-fn-gen.py: -------------------------------------------------------------------------------- 1 | 2 | code = """ 3 | LPlus ArithTy | LMinus ArithTy | LTimes ArithTy 4 | | LUDiv IntTy | LSDiv ArithTy | LURem IntTy | LSRem ArithTy 5 | | LAnd IntTy | LOr IntTy | LXOr IntTy | LCompl IntTy 6 | | LSHL IntTy | LLSHR IntTy | LASHR IntTy 7 | | LEq ArithTy | LLt IntTy | LLe IntTy | LGt IntTy | LGe IntTy 8 | | LSLt ArithTy | LSLe ArithTy | LSGt ArithTy | LSGe ArithTy 9 | | LSExt IntTy IntTy | LZExt IntTy IntTy | LTrunc IntTy IntTy 10 | | LStrConcat | LStrLt | LStrEq | LStrLen 11 | | LIntFloat IntTy | LFloatInt IntTy | LIntStr IntTy | LStrInt IntTy 12 | | LFloatStr | LStrFloat | LChInt IntTy | LIntCh IntTy 13 | | LBitCast ArithTy ArithTy 14 | | LFExp | LFLog | LFSin | LFCos | LFTan | LFASin | LFACos | LFATan 15 | | LFATan2 | LFSqrt | LFFloor | LFCeil | LFNegate 16 | 17 | | LStrHead | LStrTail | LStrCons | LStrIndex | LStrRev | LStrSubstr 18 | | LReadStr | LWriteStr 19 | | LSystemInfo 20 | | LFork 21 | | LPar 22 | | LExternal Name 23 | | LCrash 24 | 25 | | LNoOp 26 | """ 27 | code = code.replace('\n', '') 28 | def ctor(lst): 29 | lst = tuple(lst) 30 | return "{0} {2} -> ComInternal \"prim-{1}\"".format(lst[0], lst[0].lower()[1:], " ".join(map(lambda _: '_', lst[1:]))) 31 | 32 | sep = '\n ' 33 | 34 | print(sep + sep.join([ctor(filter(lambda _: _, each.split(' '))) for each in code.split('|')])) 35 | --------------------------------------------------------------------------------