Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
Confirm working support of bytestring for #40
Browse files Browse the repository at this point in the history
  • Loading branch information
TerrorJack committed Dec 3, 2018
1 parent e0026b1 commit b1f3c0c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ See the [help text](https://tweag.github.io/asterius/ahc-link) of `ahc-link` for
What works currently:

* All GHC language features except Template Haskell.
* Non-IO parts in `ghc-prim`/`integer-simple`/`base`/`array`/`deepseq`/`containers`/`transformers`/`mtl`/`pretty`. IO is achieved via rts primitives like `print_i64` or JavaScript FFI.
* Non-IO parts in `ghc-prim`/`integer-simple`/`base`/`array`/`deepseq`/`containers`/`transformers`/`mtl`/`pretty`/`bytestring`. IO is achieved via rts primitives like `print_i64` or JavaScript FFI.
* Importing JavaScript expressions via the `foreign import javascript` syntax. First-class `JSRef` type in Haskell land.
* Calling Haskell functions from JavaScript via the `foreign export javascript` syntax. Haskell closures can be passed between Haskell/JavaScript boundary via `StablePtr`.
* Invoking RTS API on the JavaScript side to manipulate Haskell closures and trigger evaluation.
Expand Down
5 changes: 3 additions & 2 deletions asterius/rts/rts.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
__asterius_wasm_instance.exports.memory.buffer,
str
);
return _str + buf.indexOf(0);
return buf.indexOf(0);
},
__asterius_memchr: (_ptr, val, num) => {
const ptr = _ptr & 0xffffffff;
Expand All @@ -346,7 +346,8 @@
ptr,
num
);
return _ptr + buf.indexOf(val);
const off = buf.indexOf(val);
return off === -1 ? 0 : _ptr + off;
},
__asterius_memcpy: (_dst, _src, n) => {
const dst = _dst & 0xffffffff,
Expand Down
3 changes: 2 additions & 1 deletion asterius/test/teletype/teletype.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import System.IO
import qualified Data.ByteString.Char8 as CBS

main :: IO ()
main = do
putStrLn "The limits of my language mean the limits of my world."
print $ CBS.pack "The limits of my language mean the limits of my world."
hPutStrLn
stderr
"The trouble with the world is that the stupid are cocksure and the intelligent are full of doubt."

0 comments on commit b1f3c0c

Please sign in to comment.