Idris 可以将 .idr 编译为 C 代码(JS、NodeJS)。是否可以反向执行 - 将 C 代码编译为 Idris 格式?或者,也许,直接在 Idris 代码中使用 C 函数?
最佳答案
当然!看看foreign function interface (FFI) .根据您的编译目标(例如 C、JavaScript 等),您可以使用 native 函数,例如在 IO< 中调用
单子(monad):void *fileOpen(char *path, char *mode)
示例
do_fopen : String -> String -> IO Ptr
do_fopen f m
= foreign FFI_C "fileOpen" (String -> String -> IO Ptr) f m
关于c - 在 Idris 中使用 C 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52578013/