Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--interface for node backend #4073

Merged
merged 11 commits into from Sep 20, 2017
Merged

Conversation

rbarreiro
Copy link
Collaborator

To address #4055 This pr adds --interface option to node backend
Example

$ cat tiface.idr
module Lib

export
ones : Int -> List Int
ones 0 = []
ones n = 1 :: (ones (n - 1))

lib : FFI_Export FFI_JS "" []
lib = Data (List Int) "List Int" $
      Fun ones "ones" $
      End
$ idris --codegen node --interface  tiface.idr -o lib.js
$ node
> l = require("./lib.js")
{ ones: [Function: Lib__ones] }
> l.ones(2)
$HC_2_1$Prelude__List___58__58_ {
  type: 1,
  '$1': 1,
  '$2': $HC_2_1$Prelude__List___58__58_ { type: 1, '$1': 1, '$2': { type: 0 } } }
> $ 

@ahmadsalim
Copy link

@rbarreiro Looks great!

Could you please add a test like ffi06 and an entry in the CHANGELOG?

@rbarreiro
Copy link
Collaborator Author

@ahmadsalim sure

@rbarreiro
Copy link
Collaborator Author

I added a test and an changelog entry, It took me a bit because I had to do some bug fixing.

@rbarreiro
Copy link
Collaborator Author

@melted I configured basic021 test to run only on c because IORef functions use the C ffi ...

@ahmadsalim
Copy link

@rbarreiro I think you need to run stylish and make a new commit please.

@melted melted merged commit 6d954d8 into idris-lang:master Sep 20, 2017
@melted
Copy link
Contributor

melted commented Sep 20, 2017

Thanks!

@goodmind
Copy link

Is this ok to export raw data structures to JS?

@rbarreiro
Copy link
Collaborator Author

rbarreiro commented Sep 21, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants