How to produce a .js file from a haskell source file with haste? -
so noticed, while answering this question, 1 asked question appears javascript developer. , code wrote in haskell easy enough, thought give haste try , try compile javascript.
so, downloaded windows binary package of haste (why .msi require reboot?!!?), added path, issued haste-cabal update
, haste-cabal install split
, after bit of reading output of hastec --help
, issued:
ps e:\h\stackoverflow> hastec -o hexagon.js --pretty-print hexagon.hs
best guess on how output looking for.
opposite expectation, haste output this:
hastec.exe: user error (shell expression failed in readmodule: data.binary.get.runget @ position 8: not enough bytes)
so, question: have java script source file?
is possible have old version of haste lying around, or have intermediate files (.jsmod
, instance) different version of compiler in source directory? sounds (quite unhelpful) error message haste produces when runs corrupted intermediate file.
check version of binary you're calling expect (hastec --version
). then, try getting rid of intermediate files in directory files in %userprofile%\appdata\roaming\haste
, reinstalling split
, , recompiling -fforce-recomp
flag. should add main
function, haste has entry point program start linking. if want make haskell function available external javascript, can use export
foreign function interface:
{-# language overloadedstrings #-} module main import haste.foreign import hexagon main = export "picture" hexagon.picture
you want compile program --onexec
flag, make sure main
runs , exports picture
when loaded, , not on page load default:
> hastec -o hexagon.js --pretty-print --onexec hexagon.hs
after doing this, code included after hexagon.js
able call e.g. haste.picture(5);
in order produce picture of size 5.
(re: msi installer requiring reboot, required since adds haste binaries %path%
, not take effect immediately. assume re-login enough make take effect, however.)
Comments
Post a Comment