-
Notifications
You must be signed in to change notification settings - Fork 642
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4073 from rbarreiro/exportiface_js
--interface for node backend
- Loading branch information
Showing
12 changed files
with
113 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Ready to show... | ||
[10, 20, 30, 40] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
l = require("./lib.js"); | ||
|
||
x = l.cons(10, l.cons(20, l.nil())); | ||
y = l.cons(30, l.cons(40, l.nil())); | ||
z = l.addLists(x, y); | ||
|
||
console.log(l.showList(z)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Lib | ||
|
||
import Data.List | ||
|
||
addLists : List Int -> List Int -> List Int | ||
addLists xs ys = xs ++ ys | ||
|
||
nil : List Int | ||
nil = [] | ||
|
||
cons : Int -> List Int -> List Int | ||
cons x xs = x :: xs | ||
|
||
show' : List Int -> JS_IO String | ||
show' xs = do putStrLn' "Ready to show..." | ||
pure (show xs) | ||
|
||
testList : FFI_Export FFI_JS "" [] | ||
testList = Data (List Int) "ListInt" $ | ||
Data (List Nat) "ListNat" $ | ||
Fun addLists "addLists" $ | ||
Fun nil "nil" $ | ||
Fun cons "cons" $ | ||
Data Nat "Nat" $ | ||
Fun Strings.length "lengthS" $ | ||
Fun show' "showList" $ | ||
End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
${IDRIS:-idris} $@ ffi011.idr --interface -o lib.js | ||
node ./ffi011 | ||
rm -f *.ibc lib.js |