Git Product home page Git Product logo

haste-compiler's Introduction

Haste

Build Status

A compiler to generate JavaScript code from Haskell.

It even has a website and a mailing list.

Features

  • Seamless, type-safe single program framework for client-server communication
  • Support for modern web technologies such as WebSockets, WebStorage and Canvas
  • Simple JavaScript interoperability
  • Generates small, fast programs
  • Supports all GHC extensions except Template Haskell
  • Uses standard Haskell libraries
  • Cabal integration
  • Simple, one-step build; no need for error prone Rube Goldberg machines of Vagrant, VirtualBox, GHC sources and other black magic
  • Concurrency and MVars with Haste.Concurrent
  • Unboxed arrays, ByteArrays, StableNames and other low level features
  • Low-level DOM base library
  • Easy integration with Google's Closure compiler
  • Works on Windows, GNU/Linux and Mac OS X

Installation

You have three options for getting Haste: installing from Hackage, from Github or from one of the pre-built binary packages. In the first two cases, you need to add add Cabal's bin directory, usually ~/.cabal/bin, to your $PATH if you haven't already done so. When installing from the Mac, portable Windows or generic Linux package, you may want to add path/to/haste-compiler/bin to your $PATH. The Debian package as well as the Windows installer and the optional install script included in the generic Linux package take care of this automatically.

Or, you can install the latest stable version from Hackage:

$ cabal install haste-compiler
$ haste-boot

Building from Github source is equally easy. After checking out the source, cd to the source tree and run:

$ cabal install
$ haste-boot --force --local

Alternatively, you may also build from Github source using Stack:

$ stack install
$ haste-boot --force --local

See doc/building.md for more information about build requirements and procedures for the various platforms.

If you are having problems with the haste-cabal installed by haste-boot, you can try building it from scratch and then passing the --no-haste-cabal flag to haste-boot:

$ git clone https://github.com/valderman/cabal.git
$ cd cabal && git checkout haste-cabal
$ cd Cabal && cabal install
$ cd ../cabal-install && cabal install

When installing Haste from GitHub, you should probably run the test suite first, to verify that everything is working. To do that, execute ./runtests.sh in the Haste root directory. You may also run only a particular test by executing ./runtests.sh NameOfTest. The test suite uses the nodejs interpreter by default, but this may be modified by setting the JS environment variable as such: JS=other-js-interpreter ./runtests.sh. Other JavaScript interpreters may or may not work. runtests.sh isn’t downloaded when installing from Hackage. You would have to download it from GitHub.

To build the patched Closure compiler used when compiling using --opt-minify, get the Closure source, apply patches/closure-argument-removal.patch and build it as you normally would. This is not usually necessary however, as haste-boot fetches a pre-compiled Closure binary when run.

For more detailed build instructions, see doc/building.md.

Haste has been tested to work on Windows and OSX platforms, but is primarily developed on GNU/Linux. As such, running on a GNU/Linux platform will likely get you less bugs.

Usage

To compile your Haskell program to a JavaScript blob ready to be included in an HTML document or run using a command line interpreter:

$ hastec myprog.hs

This is equivalent to calling ghc --make myprog.hs; Main.main will be called as soon as the JS blob has finished loading.

You can pass the same flags to hastec as you'd normally pass to GHC:

$ hastec -O2 -fglasgow-exts myprog.hs

Haste also has its own set of command line arguments. Invoke it with --help to read more about them. In particular --opt-all, --opt-minify, --start and --with-js should be fairly interesting.

If you want your package to compile with both Haste and, say, GHC, you might want to use the CPP extension for conditional compilation. Haste defines the preprocessor symbol __HASTE__ in all modules it compiles. This symbol may also be used to differentiate between Haste versions, since it is defined as an integer representation of the current Haste version. Its format is MAJOR*10 000 + MINOR*100 + MICRO. Version 1.2.3 would thus be represented as 10203, and 0.4.3 as 403.

Haste also comes with wrappers for cabal and ghc-pkg, named haste-cabal and haste-pkg respectively. You can use them to install packages just as you would with vanilla GHC and cabal:

$ haste-cabal install mtl

Finally, you can interact with JavaScript code using the Haste.Foreign module in the bundled haste-lib library. See doc/js-externals.txt for more information about that. This library also contains all sorts of functionality for DOM manipulation, event handling, preemptive multitasking, canvas graphics, native JS string manipulation, etc.

For more information on how Haste works, see the Haste Report, though beware that parts of Haste may have changed quite a bit.

You should also have a look at the documentation and/or source code for haste-lib, which resides in the libraries/haste-lib directory, and the small programs in the examples directory, to get started.

Interfacing with JavaScript

When writing programs you will probably want to use some native JavaScript in your program; bindings to native libraries, for instance. The preferred way of doing this is the Haste.Foreign module:

{-# LANGUAGE OverloadedStrings #-}
import Haste.Foreign

addTwo :: Int -> Int -> IO Int
addTwo = ffi "(function(x, y) {return x + y;})"

The ffi function is a little bit safer than the GHC FFI in that it enforces some type invariants on values returned from JS, and is more convenient. Performance-wise, it is roughly as fast as the GHC FFI except for complex types (lists, records, etc.) where it is an order of magnitude faster.

If you do not feel comfortable throwing out your entire legacy JavaScript code base, you can export selected functions from your Haste program and call them from JavaScript:

fun.hs:

{-# LANGUAGE OverloadedStrings #-}
import Haste.Foreign
import Haste.Prim (toJSStr)

fun :: Int -> String -> IO String
fun n s = return $ "The number is " ++ show n ++ " and the string is " ++ s

main = do
  export "fun" fun

legacy.js:

function mymain() {
  console.log(Haste.fun(42, "hello"));
}

...then compile with:

$ hastec '--start=$HASTE_MAIN(); mymain();' --with-js=legacy.js fun.hs

fun.hs will export the function fun when its main function is run. Our JavaScript obviously needs to run after that, so we create our "real" main function in legacy.js. Finally, we tell the compiler to start the program by first executing Haste's main function (the $HASTE_MAIN gets replaced by whatever name the compiler chooses for the Haste main) and then executing our own mymain.

The mechanics of Haste.Foreign are described in detail in this paper.

Effortless type-safe client-server communication

Using the framework from the Haste.App module hierarchy, you can easily write web applications that communicate with a server without having to write a single line of AJAX/WebSockets/whatever. Best of all: it's completely type safe.

In essence, you write your web application as a single program - no more forced separation of your client and server code. You then compile your program once using Haste and once using GHC, and the two compilers will magically generate client and server code respectively.

You will need to have the same libraries installed with both Haste and vanilla GHC (unless you use conditional compilation to get around this). haste-compiler comes bundled with all of haste-lib, so you only need to concern yourself with this if you're using third party libraries. You will also need a web server, to serve your HTML and JS files; the binary generated by the native compilation pass only communicates with the client part using WebSockets and does not serve any files on its own.

Examples of Haste.App in action is available in examples/haste-app and examples/chatbox.

For more information about how exactly this works, see this paper.

Base library and documentation

You can build your own set of docs for haste-lib by running cabal haddock in the Haste base directory as with any other package.

Or you could just look at the online docs.

Libraries

Haste is able to use standard Haskell libraries. However, some primitive operations are still not implemented which means that any code making use of them will give you a compiler warning, then die at runtime with an angry error. Some libraries also depend on external C code - if you wish to use such a library, you will need to port the C bits to JavaScript yourself (perhaps using Emscripten) and link them into your program using --with-js.

Known issues

  • Not all GHC primops are implemented; if you encounter an unimplemented primop, please report it together with a small test case that demonstrates the problem.

  • Template Haskell is still broken.

  • Generated code is not compatible with the vanilla Closure compiler's ADVANCED_OPTIMIZATIONS, as it is not guaranteed to preserve Function.length. haste-boot bundles a compatibility patched version of Closure which does preserve this property. Invoking hastec with the --opt-minify option will use this patched version to minify the generated code with advanced optimizations.

haste-compiler's People

Contributors

ababkin avatar ahri avatar apatil avatar avieth avatar aycanirican avatar cpressey avatar crodjer avatar emilaxelsson avatar emilv avatar ericmoritz avatar geraldus avatar hugodaniel avatar joshcheek avatar jtojnar avatar klarh avatar koengit avatar kranich avatar laszlopandy avatar mbrodersen avatar mcandre avatar minoki avatar nickgeoca avatar nyson avatar ozataman avatar reem avatar rudolfvonkrugstein avatar soenkehahn avatar takeoutweight avatar valderman avatar vermeille avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

haste-compiler's Issues

Nested Data.Set#foldr Results in Runtime Error When Compiled With Optimizations

The following code produces this error message when compiled with -O1 or -O2: Uncaught TypeError: undefined is not a function.

import Haste
import Data.Set (Set)
import qualified Data.Set as S

main = alert $ show $ S.toList $ S.map S.toList $ cartProd xs ys

xs = S.fromList "abc"
ys = S.fromList "def"

cartProd xs ys = S.foldr outerFold S.empty xs
  where outerFold x zss = S.foldr (innerFold x) S.empty ys `S.union` zss
        innerFold x y zs = S.fromList [x,y] `S.insert` zs

This affects foldr', foldl and foldl' as well:

cartProd' xs ys = S.foldl outerFold S.empty xs
  where outerFold zss x = S.foldl (innerFold x) S.empty ys `S.union` zss
        innerFold x zs y = S.fromList [x,y] `S.insert` zs

Till

haste-inst doesn't recognize cabal flags

It seems to me that haste-inst doesn't recognize cabal flags passed as, say haste-inst install reactive-banana -f-UseGHC. I need this to make compilation conditional.

Unfortunately, I am not able to provide a minimal example at the time. I can offer a test environment for reactive-banana, though. Simply check out the commit

https://github.com/HeinrichApfelmus/reactive-banana/tree/0d933257f615271930395a8a8041d3063676f70b

EDIT: you also need the latest github version of the vault library in a parent directory. Sorry about that.

and run

 cd haste
 make libraries

The haste-inst program will attempt to build the text library, but I have excluded this dependency in the cabal file reactive-banana/reactive-banana.cabal via the UseGHC flag.

Building libs fails on Mac OS / GHC 7.6.3

Here's the output:

phils-MacBook-Pro:haste-compiler phil$ ./buildlibs.sh
Reading package info from "libraries/rts.pkg" ... done.
~/Projects/haskell/haste-compiler ~/Projects/haskell/haste-compiler
Resolving dependencies...
Configuring ghc-prim-0.3.0.0...
Building ghc-prim-0.3.0.0...
Preprocessing library ghc-prim-0.3.0.0...
Compiling GHC.Classes into /Users/phil/.haste/lib
Compiling GHC.Magic into /Users/phil/.haste/lib
Compiling GHC.Tuple into /Users/phil/.haste/lib
Compiling GHC.Types into /Users/phil/.haste/lib
Compiling GHC.CString into /Users/phil/.haste/lib
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
WARNING: Unsupported PrimOp: indexCharOffAddr#
Compiling GHC.Debug into /Users/phil/.haste/lib
Compiling GHC.IntWord64 into /Users/phil/.haste/lib
In-place registering ghc-prim-0.3.0.0...
Installing dist/build/GHC/Classes.hi...
Installing dist/build/GHC/CString.hi...
Installing dist/build/GHC/Debug.hi...
Installing dist/build/GHC/IntWord64.hi...
Installing dist/build/GHC/Magic.hi...
Installing dist/build/GHC/Tuple.hi...
Installing dist/build/GHC/Types.hi...
Reading package info from "packageconfig" ... done.
~/Projects/haskell/haste-compiler
~/Projects/haskell/haste-compiler ~/Projects/haskell/haste-compiler
Resolving dependencies...
In order, the following will be installed:
integer-gmp-0.5.0.0 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Configuring integer-gmp-0.5.0.0...
Building integer-gmp-0.5.0.0...
Preprocessing library integer-gmp-0.5.0.0...
Compiling GHC.Integer into /Users/phil/.haste/lib
Compiling GHC.Integer.Type into /Users/phil/.haste/lib
WARNING: Word literal 18446744073709551615 doesn't fit in 32 bits; truncating!
Compiling GHC.Integer.GMP.Internals into /Users/phil/.haste/lib
Compiling GHC.Integer.GMP.Prim into /Users/phil/.haste/lib
Compiling GHC.Integer.Logarithms into /Users/phil/.haste/lib
Compiling GHC.Integer.Logarithms.Internals into /Users/phil/.haste/lib
In-place registering integer-gmp-0.5.0.0...
Installing library in
/Users/phil/.haste/haste-install/lib/integer-gmp-0.5.0.0/ghc-7.6.3
Registering integer-gmp-0.5.0.0...
Installed integer-gmp-0.5.0.0
Resolving dependencies...
In order, the following will be installed:
integer-gmp-0.5.0.0 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Configuring integer-gmp-0.5.0.0...
Building integer-gmp-0.5.0.0...
Preprocessing library integer-gmp-0.5.0.0...
Compiling GHC.Integer into /Users/phil/.haste/lib
Compiling GHC.Integer.Type into /Users/phil/.haste/lib
WARNING: Word literal 18446744073709551615 doesn't fit in 32 bits; truncating!
Compiling GHC.Integer.GMP.Internals into /Users/phil/.haste/lib
Compiling GHC.Integer.GMP.Prim into /Users/phil/.haste/lib
Compiling GHC.Integer.Logarithms into /Users/phil/.haste/lib
Compiling GHC.Integer.Logarithms.Internals into /Users/phil/.haste/lib
In-place registering integer-gmp-0.5.0.0...
Installing library in
/Users/phil/.haste/haste-install/lib/integer-gmp-0.5.0.0/ghc-7.6.3
Registering integer-gmp-0.5.0.0...
Installed integer-gmp-0.5.0.0
~/Projects/haskell/haste-compiler
~/Projects/haskell/haste-compiler ~/Projects/haskell/haste-compiler
Resolving dependencies...
Configuring base-4.6.0.1...
Warning: Instead of 'ghc-options: -DHASTE_HOST_WORD_SIZE_IN_BITS=64' use
'cpp-options: -DHASTE_HOST_WORD_SIZE_IN_BITS=64'
Building base-4.6.0.1...
Preprocessing library base-4.6.0.1...
In file included from /Users/phil/.haste/include/Rts.h:216,
                 from Stack.hsc:45:
/Users/phil/.haste/include/rts/storage/Block.h: In function ‘Bdescr’:
/Users/phil/.haste/include/rts/storage/Block.h:137: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/Block.h:138: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/Block.h:139: warning: cast to pointer from integer of different size
/Users/phil/.haste/include/rts/storage/Block.h: In function ‘round_to_mblocks’:
/Users/phil/.haste/include/rts/storage/Block.h:272: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/Block.h:276: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/Block.h:284: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/Block.h: In function ‘round_up_to_mblocks’:
/Users/phil/.haste/include/rts/storage/Block.h:292: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/Block.h:294: warning: cast from pointer to integer of different size
In file included from /Users/phil/.haste/include/Rts.h:217,
                 from Stack.hsc:45:
/Users/phil/.haste/include/rts/storage/ClosureMacros.h: In function ‘GET_CLOSURE_TAG’:
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:182: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/ClosureMacros.h: In function ‘UNTAG_CLOSURE’:
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:188: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:188: warning: cast to pointer from integer of different size
/Users/phil/.haste/include/rts/storage/ClosureMacros.h: In function ‘TAG_CLOSURE’:
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:194: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:194: warning: cast to pointer from integer of different size
/Users/phil/.haste/include/rts/storage/ClosureMacros.h: In function ‘LOOKS_LIKE_INFO_PTR_NOT_NULL’:
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:224: warning: cast to pointer from integer of different size
/Users/phil/.haste/include/rts/storage/ClosureMacros.h: In function ‘LOOKS_LIKE_CLOSURE_PTR’:
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:235: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/ClosureMacros.h: In function ‘stack_frame_sizeW’:
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:402: warning: cast from pointer to integer of different size
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:402: warning: cast to pointer from integer of different size
/Users/phil/.haste/include/rts/storage/ClosureMacros.h:405: warning: cast to pointer from integer of different size
In file included from /Users/phil/.haste/include/Rts.h:237,
                 from Stack.hsc:45:
/Users/phil/.haste/include/rts/Stable.h: In function ‘deRefStablePtr’:
/Users/phil/.haste/include/rts/Stable.h:37: warning: cast from pointer to integer of different size
ld: library not found for -lrt
collect2: ld returned 1 exit status
linking dist/build/GHC/Stack_hsc_make.o failed (exit code 1)
command was: /usr/bin/gcc dist/build/GHC/Stack_hsc_make.o dist/build/GHC/Stack_hsc_utils.o -o dist/build/GHC/Stack_hsc_make -m64 -m64 -L/Users/phil/.haste/haste-install/lib/integer-gmp-0.5.0.0/ghc-7.6.3 -L/Users/phil/.haste/haste-install/lib/ghc-prim-0.3.0.0 -L/Users/phil/.haste/haste-install/lib -lffi -lm -lrt -ldl
~/Projects/haskell/haste-compiler
~/Projects/haskell/haste-compiler ~/Projects/haskell/haste-compiler
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: array-0.4.0.1
rejecting: base-3.0.3.2, 3.0.3.1 (conflict: array => base>=4.2 && <5)
rejecting: base-4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0,
4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0 (only already installed instances can be
used)
rejecting: base-4.1.0.0, 4.0.0.0 (conflict: array => base>=4.2 && <5)
~/Projects/haskell/haste-compiler
~/Projects/haskell/haste-compiler ~/Projects/haskell/haste-compiler
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: fursuit-0.1
rejecting: base-3.0.3.2 (conflict: base => base>=4.0 && <4.3)
rejecting: base-3.0.3.1 (conflict: base => base>=4.0 && <4.2)
rejecting: base-4.6.0.1, 4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0,
4.3.0.0, 4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0 (only already installed
instances can be used)
~/Projects/haskell/haste-compiler
~/Projects/haskell/haste-compiler ~/Projects/haskell/haste-compiler
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: haste-lib-0.1
rejecting: base-3.0.3.2, 3.0.3.1 (conflict: haste-lib => base==4.6.0.1)
rejecting: base-4.6.0.1 (only already installed instances can be used)
rejecting: base-4.6.0.0, 4.5.1.0, 4.5.0.0, 4.4.1.0, 4.4.0.0, 4.3.1.0, 4.3.0.0,
4.2.0.2, 4.2.0.1, 4.2.0.0, 4.1.0.0, 4.0.0.0 (conflict: haste-lib =>
base==4.6.0.1)
~/Projects/haskell/haste-compiler
Downloading Google Closure compiler...

And my list of installed packages:

/Library/Frameworks/GHC.framework/Versions/7.6.3-x86_64/usr/lib/ghc-7.6.3/package.conf.d
   Cabal-1.16.0
   GLURaw-1.3.0.0
   GLUT-2.4.0.0
   HTTP-4000.2.8
   HUnit-1.2.5.2
   OpenGL-2.8.0.0
   OpenGLRaw-1.3.0.0
   QuickCheck-2.6
   array-0.4.0.1
   async-2.0.1.4
   attoparsec-0.10.4.0
   base-4.6.0.1
   bin-package-db-0.0.0.0
   binary-0.5.1.1
   bytestring-0.10.0.2
   case-insensitive-1.0.0.1
   cgi-3001.1.7.5
   containers-0.5.0.0
   deepseq-1.3.0.1
   directory-1.2.0.1
   fgl-5.4.2.4
   filepath-1.3.0.1
   ghc-7.6.3
   ghc-prim-0.3.0.0
   hashable-1.1.2.5
   haskell-platform-2013.2.0.0
   haskell-src-1.0.1.5
   haskell2010-1.1.1.0
   haskell98-2.0.0.2
   hoopl-3.9.0.0
   hpc-0.6.0.0
   html-1.0.1.2
   integer-gmp-0.5.0.0
   mtl-2.1.2
   network-2.4.1.2
   old-locale-1.0.0.5
   old-time-1.1.0.1
   parallel-3.2.0.3
   parsec-3.1.3
   pretty-1.1.1.0
   primitive-0.5.0.1
   process-1.1.0.2
   random-1.0.1.1
   regex-base-0.93.2
   regex-compat-0.95.1
   regex-posix-0.95.2
   rts-1.0
   split-0.2.2
   stm-2.4.2
   syb-0.4.0
   template-haskell-2.8.0.0
   text-0.11.3.1
   time-1.4.0.1
   transformers-0.3.0.0
   unix-2.6.0.1
   unordered-containers-0.2.3.0
   vector-0.10.0.1
   xhtml-3000.2.1
   zlib-0.5.4.1
/Users/phil/.ghc/x86_64-darwin-7.6.3/package.conf.d
   bzlib-0.5.0.4
   cereal-0.3.5.2
   curl-1.3.8
   digest-0.0.1.2
   download-curl-0.1.4
   feed-0.3.8
   ghc-paths-0.1.0.9
   tagsoup-0.12.8
   tar-0.4.0.1
   utf8-string-0.3.7
   xml-1.3.13
   zip-archive-0.1.3.4

It seems that Stack_hsc_make fails to build and array causes a version conflict. This is on a clean GHC install after running uninstall-hs.

Something is not right with --opt-tce

Running the Exception test with --opt-tce gives the wrong result, as both arguments to hs_eqWord64 are undefined.

A tempting solution is to remove --opt-tce entirely, since the full tail call elimination seems a bit unnecessary when tail recursion to loop conversion (which is always performed) takes care of the most important use cases anyway.

window.onload and how to call member functions in js

This is not an issue, but a question. But I did not know where else to ask.
When interfacing with javascript, I sometimes want to call member functions of an object from haskell. For example, I have the document, and want to call document.write. Does the FFI allow this is some way?

Also, examining the output of hastec, I am correct with the assumption that the main functions is set to window.onload?

failed to build on OSX 10.6.8

Configuring haste-compiler-0.1...
Building haste-compiler-0.1...
Preprocessing library haste-compiler-0.1...
[ 1 of 12] Compiling Haste.Prim ( src/Haste/Prim.hs, dist/build/Haste/Prim.o )
[ 2 of 12] Compiling Haste.DOM ( src/Haste/DOM.hs, dist/build/Haste/DOM.o )
[ 3 of 12] Compiling Haste.Random ( src/Haste/Random.hs, dist/build/Haste/Random.o )
[ 4 of 12] Compiling Haste.Callback ( src/Haste/Callback.hs, dist/build/Haste/Callback.o )
[ 5 of 12] Compiling Haste.Showable ( src/Haste/Showable.hs, dist/build/Haste/Showable.o )
[ 6 of 12] Compiling Haste.Readable ( src/Haste/Readable.hs, dist/build/Haste/Readable.o )
[ 7 of 12] Compiling Haste ( src/Haste.hs, dist/build/Haste.o )
[ 8 of 12] Compiling Haste.JSON ( src/Haste/JSON.hs, dist/build/Haste/JSON.o )
[ 9 of 12] Compiling Haste.Ajax ( src/Haste/Ajax.hs, dist/build/Haste/Ajax.o )
[10 of 12] Compiling Haste.Reactive.Ajax ( src/Haste/Reactive/Ajax.hs, dist/build/Haste/Reactive/Ajax.o )
[11 of 12] Compiling Haste.Reactive.DOM ( src/Haste/Reactive/DOM.hs, dist/build/Haste/Reactive/DOM.o )
[12 of 12] Compiling Haste.Reactive ( src/Haste/Reactive.hs, dist/build/Haste/Reactive.o )
Registering haste-compiler-0.1...
Preprocessing executable 'hastecat' for haste-compiler-0.1...
: cannot satisfy -package-id mtl-2.1.1-ae9b44386a2528180e60dcf2412689c0
(use -v for more information)
Unable to build Haste, and I have no idea why. :(

haste-boot fails: haddock internal error

Trace:

$ haste-boot

...

Running Haddock for fursuit-0.1...
Warning: The documentation for the following packages are not installed. No
links will be generated to these packages: array-0.4.0.1, rts-1.0,
containers-0.5.1.0, deepseq-1.3.0.1
Preprocessing library fursuit-0.1...
haddock: internal error: dist/build/tmp-61851/src/FRP/Fursuit.hs/settings: openFile: inappropriate type (Not a directory)
Installing library in /Users/andrew/.haste/haste-install/lib
Registering fursuit-0.1...
OK!
Attempting to clone/update: git://github.com/valderman/haste-compiler.git
fatal: Not a git repository (or any of the parent directories): .git
haste-boot: Failed!

Specs:

cabal --version
cabal-install version 0.14.0
using version 1.14.0 of the Cabal library 

ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.4.1

ghc-pkg field haskell-platform version
version: 2012.2.0.0

system_profiler SPSoftwareDataType | grep 'System Version'
      System Version: OS X 10.8.2 (12C60)

Package hashable is unbuildable

The package hashable is unbuildable since it depends on the internal workings of integer-gmp:Integer.

Three possible solutions: get a tiny patch accepted into hashable, distribute our own patched version, or bend over backwards to give Integer an internal structure that hashable is happy with.

Implementation of log2 infinite-loops on 0

The built-in Javascript Math.log returns -Infinity when passed 0, but the implementation provided in the Haste library goes into an infinite loop.

Unrelatedly: is the source for the library available? I can only find it distributed as the .jsmod files.

Calling a callback of type IO () twice

Hey,

I have the following code example:

import Haste
foreign import ccall "callTwice" callTwice :: JSFun (IO ()) -> IO ()

main = do
  callTwice (mkCallback $ (alert "Hello World"))

js part:

function callTwice(f) {
  A(f,[0]);
  A(f,[0]);
  return;
}

What is happening is, that the "Hello World" alert gets executed only once!

How can I force the function to be executed twice?

Unsupported PrimOp when compiling reactive banana

Hey,

I am trying to get reactive banana compile with haste. (It has been made to work with UHC: HeinrichApfelmus/reactive-banana#30).

So I tried and got:

Compiling Reactive.Banana into /home/ls/.haste/lib
Compiling Reactive.Banana.Combinators into /home/ls/.haste/lib
Compiling Reactive.Banana.Frameworks into /home/ls/.haste/lib
WARNING: Unsupported PrimOp: putMVar#
WARNING: Unsupported PrimOp: takeMVar#
WARNING: Unsupported PrimOp: newMVar#
WARNING: Unsupported PrimOp: atomically#
WARNING: Unsupported PrimOp: makeStableName#
WARNING: Unsupported PrimOp: seq#
WARNING: Unsupported PrimOp: atomically#
WARNING: Unsupported PrimOp: makeStableName#
WARNING: Unsupported PrimOp: seq#
WARNING: Unsupported PrimOp: atomically#
WARNING: Unsupported PrimOp: stableNameToInt#
WARNING: Unsupported PrimOp: stableNameToInt#
WARNING: Unsupported PrimOp: putMVar#
WARNING: Unsupported PrimOp: newMVar#
WARNING: Unsupported PrimOp: putMVar#
WARNING: Unsupported PrimOp: takeMVar#
Compiling Reactive.Banana.Model into /home/ls/.haste/lib
Compiling Reactive.Banana.Internal.InputOutput into /home/ls/.haste/lib
WARNING: Unsupported PrimOp: makeStableName#
WARNING: Unsupported PrimOp: seq#
WARNING: Unsupported PrimOp: atomically#
WARNING: Unsupported PrimOp: makeStableName#
WARNING: Unsupported PrimOp: seq#
WARNING: Unsupported PrimOp: atomically#
Compiling Reactive.Banana.Internal.CompileModel into /home/ls/.haste/lib
WARNING: Unsupported PrimOp: stableNameToInt#
WARNING: Unsupported PrimOp: stableNameToInt#
WARNING: Unsupported PrimOp: seq#

The UHC solution provides an MVar based on IORef which works because there are no threads in javascript.
Unfortantly I have not found out how to install this version and remove the warning from haste ...

What than is missing is

  • makeStableName
  • seq
  • atomically
  • stableNameToInt

Maybe js solutions for this can be found.

setCallback does not really make sense for OnKeyDown and OnKeyUp

Hey,

With setCallback I can set a callback function to be executed on several events including onKeyDown and onKeyUp.
But setCallback does not allow the callback function to have a parameter. Normally, when I want to get onKeyDown and onKeyUp events, I would also know the keycode and that is given in the parameter.
Or am I missing something?

eval.js missing

Hi Anton,
I'm very excited to check out the haste compiler. However, when I try to run the buildall.sh script the step that runs this code:
"runghc Setup.hs install" returns "Setup.hs: lib/eval.js: does not exist".
It seems to me there there are some files missing from the git repository.
Best!

  • Mike

Runtime bug in compiled program.

I am able to compile reactive-banana by telling haste to compile all dependency source files at the same time.

However, the resulting program doesn't work and throws the JavaScript error

Uncaught TypeError: Cannot read property '1' of null 

Unfortunately, I have not been able to distill a minimal example. Reactive-banana uses several techniques that are not referentially transparent, like observable sharing and unsafePerformIO, so there might be some problems there, but I really can't tell. Also, I am using value recursion, but it appears that the instance MonadFix IO instance works fine haste, so that should be ok, but I don't understand the interactions.

I have checked that the code used for the haste version of reactive-banana compiles and works under GHC. In particular, my custom implementation of Data.HashMap is correct as far as I can tell.

To try out the full code, check out the repository

https://github.com/HeinrichApfelmus/reactive-banana/tree/0d933257f615271930395a8a8041d3063676f70b

and download the latest version of vault

https://github.com/HeinrichApfelmus/vault/tree/b944d14393f9bba67f3fdba7c29b9c72e2610f8e

into the parent directory, which should now contain two folders reactive-banana and vault. Then, do

 cd reactive-banana/haste
 make single

to compile the example program. The result can be viewed in the corresponding html file.

data-lens-template does not work

When compiling this test

{-# LANGUAGE TemplateHaskell #-}

module Test where

import Data.Lens.Lazy
import Data.Lens.Template

data Paddle     = Paddle { _xPos    :: Double }

$( makeLens ''Paddle )

I get:

Test.hs:10:4:
    Illegal type variable name: `'
    When splicing a TH declaration: Test.xPos :: forall . 

While in ghc it works. Maybe template haskell does not work?

Could not find module `Haste'

Just installed hastec, and it fails on any Haste or Fursuit imports. Upgraded from GHC 7.4.1 to 7.4.2 just in case, same error. Any ideas?

# cat HelloWorld.hs 
import Haste
main = writeLog "Hello, world!"

# hastec -v HelloWorld.hs 
Using binary package database: /home/skligys/.haste/haste-pkg/package.cache
wired-in package ghc-prim mapped to ghc-prim-0.2.0.0-7d3c2c69a5e8257a04b2c679c40e2fa7
wired-in package integer-gmp mapped to integer-gmp-0.4.0.0-af3a28fdc4138858e0c7c5ecc2a64f43
wired-in package base mapped to base-4.5.1.0-6e4c9bdc36eeb9121f27ccbbcb62e3f3
wired-in package rts mapped to builtin_rts
wired-in package template-haskell not found.
wired-in package dph-seq not found.
wired-in package dph-par not found.
*** Chasing dependencies:
Chasing modules from: *HelloWorld.hs
hastec: panic! (the 'impossible' happened)
  (GHC version 7.4.2 for x86_64-unknown-linux):
        Could not find module `Haste'
Locations searched:
  Haste.hs
  Haste.lhs

Put generated code in non-global scope

The haste compiler currently put all RTS functions and generated code in the global scope. Placing definitions in this scope is considered extremely bad practice in JavaScript and can lead to very bad interactions with libraries or other scripts code running on the same web page in case of name collisions.

The accepted practice for a JavaScript library is to define a single global symbol per application and put all private variables inside a local function scope. For example:

MyUniquelyNamedJsLibrary = (function() {
  var k1 = 123736587281;    // exported
  var v1 = 012738281787;    // non-exported 

  var foo = function () {   // exported
    // ...
  }
  var bar = function () {   // exported
    // ...
  }
  var baz = function () {   // non-exported
    // ...
  }

  return {
    "k1"  : k1,
    "foo" : foo,  
    "bar" : bar   
  };
}()); 

Proposed solution for Haste

Each generated JavaScript blob should define a single uniquely named function. Its name can be set on the command line (usually Main). All RTS functions and genrated variables goes inside its scope, but included JavaScript code goes outside it. It returns the evaluated main function.

// ... all included JavaScript code
var Main = (function () {
  function E () {}                  // ... all RTS functions
  var _1 =                          // ... all generated var definitions
  return function(){E(E(_n)(0))};   // the main function
}());

The compiler can optionally generate a final line such as:

window.onload = Main;

This should be optional, as the user may prefer to use another event for main, such as jQuery(document).ready(Main).

Can't build a haste library

I have the following errors when I run ./buildlibs.sh

Konstantins-MacBook-Pro-2:haste-compiler kostik$ ./buildlibs.sh
Reading package info from "libraries/rts.pkg" ... done.
~/Sources/haste-compiler ~/Sources/haste-compiler
cabal: Cannot find the program 'ghc-pkg' at 'haste-pkg' or on the path
cabal: Run the 'configure' command first.
haste-install-his: dist/build: getDirectoryContents: does not exist (No such file or directory)
Reading package info from "packageconfig" ... done.
ghc-prim-0.3.0.0: Warning: library-dirs: /Users/kostik/.haste/haste-install/lib/ghc-prim-0.3.0.0 doesn't exist or isn't a directory
ghc-prim-0.3.0.0: import-dirs: /Users/kostik/.haste/haste-install/lib/ghc-prim-0.3.0.0 doesn't exist or isn't a directory (use --force to override)
ghc-prim-0.3.0.0: file GHC/Classes.hi is missing (use --force to override)
ghc-prim-0.3.0.0: file GHC/CString.hi is missing (use --force to override)
ghc-prim-0.3.0.0: file GHC/Debug.hi is missing (use --force to override)
ghc-prim-0.3.0.0: file GHC/Magic.hi is missing (use --force to override)
ghc-prim-0.3.0.0: file GHC/IntWord64.hi is missing (use --force to override)
ghc-prim-0.3.0.0: file GHC/Tuple.hi is missing (use --force to override)
ghc-prim-0.3.0.0: file GHC/Types.hi is missing (use --force to override)
~/Sources/haste-compiler
~/Sources/haste-compiler ~/Sources/haste-compiler
cabal: Cannot find the program 'ghc-pkg' at 'haste-pkg' or on the path
cabal: Cannot find the program 'ghc-pkg' at 'haste-pkg' or on the path
~/Sources/haste-compiler
~/Sources/haste-compiler ~/Sources/haste-compiler
cabal: Cannot find the program 'ghc-pkg' at 'haste-pkg' or on the path
cabal: Run the 'configure' command first.
haste-install-his: dist/build: getDirectoryContents: does not exist (No such file or directory)
~/Sources/haste-compiler
~/Sources/haste-compiler ~/Sources/haste-compiler
cabal: Cannot find the program 'ghc-pkg' at 'haste-pkg' or on the path
~/Sources/haste-compiler
~/Sources/haste-compiler ~/Sources/haste-compiler
cabal: Cannot find the program 'ghc-pkg' at 'haste-pkg' or on the path
~/Sources/haste-compiler
~/Sources/haste-compiler ~/Sources/haste-compiler
cabal: Cannot find the program 'ghc-pkg' at 'haste-pkg' or on the path
~/Sources/haste-compiler
Downloading Google Closure compiler...

Unable to download base libs

When running haste-boot, I get an error:

haste-boot: Unable to download base libs: Failed to connect: CurlCouldntConnect

Tried going to the dir, it looks like its no longer hosted there.

So I tried to run the "Building your own base libraries" instead, but can't install haskell from hackage without darcs, which is apparently not on homebrew. Started to download darcs, but found haskell on the github repo repo instead.

I edited the mk/build.mk script. There is no ./config, so I need to run perl boot. But when I run that, it wants me to ./sync-all get because there is no ghc-tarballs/LICENSE. So I do, but perl boot still dies at the same point, saying the same thing. Here is the code.

I thought about just touching the license file, but I don't even have a ghc-tarballs directory to put the license in, so I'm pretty sure that's getting around the check, but not solving the problem.

Not really sure what to do.

Bad js generated with -O2: Bool result is not shown in NineConstructors

Compile:
hastec --start=asap --debug -O2 -DTEST_MODULE=NineConstructors TestDriver.hs

When run, the output is empty (as opposed to O0, which prints False).

When inspecting generated output, it seems to be incorrect (maybe related to #41 ?):

var _a/*GHC.Show.shows32*/ = function(_b){
  return _1/*GHC.Base.++*/(_9/*GHC.Show.shows33*/,_b);
};
var _c/*Main.main2*/ = T(function(){
  return toJSStr(_a/*GHC.Show.shows32*/);
});

_a has 1 argument, but when passed to toJSStr in _c, no parameter is applied for _a

Deriving Eq For Data Type With More Than Eight Constructors Makes All Constructors Equal

The output of the following programm is True but it should be False

import Haste
data T = T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 deriving Eq
main = alert $ show $ T1 == T2

For data types with up to eight constructors everything works correctly though (the result is False)

import Haste
data T = T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 deriving Eq
main = alert $ show $ T1 == T2

Deriving by hand makes it work but is quite messy

instance Eq T where
  T1 == T1 = True
  T2 == T2 = True
  T3 == T3 = True
  T4 == T4 = True
  T5 == T5 = True
  T6 == T6 = True
  T7 == T7 = True
  T8 == T8 = True
  T9 == T9 = True
  _  == _  = False

Uncaught SyntaxError: Unexpected token ;

I get the following error in a compiled program:

Uncaught SyntaxError: Unexpected token ; 

This is the compiled code around the error:

var _Kh/*Graphics.Cocos2d.Action.a55*/ = function(_Ki,_){
    while(1)    {
        var r=(function(_Kj,;n__){ //<- this is the line with the error
            var _Kk = function(;n__){
                return     _Eh/*Control.Exception.Base.patError*/("../../src/Graphics/Cocos2d/Action.hs:(57,1)-(121,21)|function toJSAction");
            };
            var _Kl = E(_Kj);
...

When I have the time I will try to find a minimal example.

Link to thesis?

Hi again Anton,

Just a though, maybe you should put a link to your thesis in the repo? I found it on the Haskell wiki by accident, having already spent several hours trying to figure out the internals of Haste by reverse engineering ;).

Great work by the way.

Cannot compile on OSX

I've installed haste using buildall.sh, and the executable runs fine, but I get the following error when I try to compile something with hastec:

$ hastec --opt-google-closure=../tools/compiler.js Main.hs
Compiling BudgetFlow into .
Compiling Main into .
Linking Main.js
Linking Main.jsmod
Linking Haste.jsmod
Linking GHC/Tuple.jsmod
/Users/haldean/.haste/lib/GHC/Tuple.jsmod: openBinaryFile: does not exist (No such file or directory)  

The contents of /Users/haldean/.haste:

$ ls -R ~/.haste
/Users/haldean/.haste/lib:
FRP     Haste       Haste.jsmod

/Users/haldean/.haste/lib/FRP:
Fursuit     Fursuit.jsmod

/Users/haldean/.haste/lib/FRP/Fursuit:
Async.jsmod Pipe.jsmod  Signal.jsmod    Sink.jsmod

/Users/haldean/.haste/lib/Haste:
Ajax.jsmod  Callback.jsmod  DOM.jsmod   JSON.jsmod  Prim.jsmod  Random.jsmod    Reactive    Reactive.jsmod    Readable.jsmod    Showable.jsmod

/Users/haldean/.haste/lib/Haste/Reactive:
Ajax.jsmod  DOM.jsmod

Bad js generated with -O2: closure not generated

Compile:
hastec --start=asap --debug -O2 -DTEST_MODULE=Elem TestDriver.hs

When run using sm js:
TestDriver.js:825: ReferenceError: _X is not defined

Indeed, _X (which is annotated to be GHC.Show.show_tuple) was not generated.

Read is broken

The Read test in the test suite fails with a "no parse" error. This is most likely due to a misbehaving library function, since they're pretty crap - especially the ones dealing with text or chars.

.jsmod files are not separated by package

.jsmod files are currently just dumped in a module hierarchy in ~/.haste/lib; this is obviously insane and will break horribly if the user installs two packages that provide the same module.

Fix: group .jsmod files by package, just like the .hi files.

parmap?

I realize that parmap would be rather difficult to implement in haste, but if we can figure out a way to do so, it would go a long way towards a fuller port of Haskell to JavaScript.

haste on 64bit ubuntu possible

The documentation says, that baselib on 64bit will not work.
When I compile on 64bit ubuntu a simple hello world project, I get:

hs_iconv_open is not defined

Is this because of the 64bit system? Is there a way to get haste on 64bit ubuntu?

Error on invoking hastec

Konstantins-MacBook-Pro-2:Tests kostik$ hastec DoubleDiv.hs
hastec: panic! (the 'impossible' happened)
(GHC version 7.6.3 for x86_64-apple-darwin):
Could not find module `Prelude'
Use -v to see a list of the files searched for.

Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug

Can not install many packages because of text

Many packages seem to have text as a dependency. When I try to install text using haste-inst I get:

(many unsupported primops)
hastec: panic! (the 'impossible' happened)
  (GHC version 7.4.2 for x86_64-unknown-linux):
    Bad data constructor tag generated!

Many of the packages worked before haste-inst (I guess I did not use any part of these packages that used text).

lifted-base can not be installed because of cabal library version

When I try to install lifted-base (it is a dependency) with haste-inst, I get:

Resolving dependencies...
In order, the following will be installed:
lifted-base-0.2 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
cabal: Error: some packages failed to install:
lifted-base-0.2 failed during the configure step. The exception was:
user error (The package requires Cabal library version -any && >=1.9.2 but no
suitable version is installed.)

buildlibs fails at haste-lib

Related output:

Resolving dependencies...
Configuring haste-lib-0.1...
Building haste-lib-0.1...
Preprocessing library haste-lib-0.1...
hastec: panic! (the 'impossible' happened)
   (GHC version 7.6.2 for x86_64-unknown-linux):
    Could not find module `Control.Monad.Cont.Class'
It is a member of the hidden package `mtl-2.1.2'.
Perhaps you need to add `mtl' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.

js interpreter for running tests

Which js interepreter do you use for running ./runtests.sh?

With rhino I get a stack overflow.

With node.js I get undefined reference to print.

atomicModifyMutVar

Hey,

I stumbled over another unsupported PrimOp: atomicModifyMutVar.
I am trying to implement this, but I struggle with the Parameters:

One Parameter is the transaction function (type a -> b).
In normal code, to pass a haskell function to js it needs to be converted with Ptr.
But I do not really understand the syntax in PrimOps.hs.
I add

AtomicModifyMutVarOp -> call "atomicModifyMV"

But I do I need to convert the callback parameter somehow?

Also: I added this line and reinstall haste with "cabal install". Still, I keep getting:

 Uncaught Unsupported PrimOp: atomicModifyMutVar# 

Is there something else I need to add?

Prolems with GHC/Desugar.jsmod

Hey,
When I try to compile a program in which I use arrow syntax, I get:

Compiling Main into .
Compiling JavaScript into .
Compiling Coroutine into .
Linking Pong.js
Linking Main.jsmod
Linking JavaScript.jsmod
Linking GHC/Tuple.jsmod
Linking Haste/Callback.jsmod
Linking Prelude.jsmod
Linking GHC/Base.jsmod
Linking GHC/IO.jsmod
Linking GHC/IO/Exception.jsmod
Linking Data/Typeable.jsmod
Linking Data/Maybe.jsmod
Linking GHC/Exception.jsmod
Linking GHC/Types.jsmod
Linking GHC/IO/Handle/Types.jsmod
Linking GHC/Show.jsmod
Linking GHC/IORef.jsmod
Linking Haste/DOM.jsmod
Linking GHC/STRef.jsmod
Linking Coroutine.jsmod
Linking GHC/Float.jsmod
Linking GHC/Err.jsmod
Linking GHC/Integer/Type.jsmod
Linking GHC/Real.jsmod
Linking GHC/Integer/Logarithms/Internals.jsmod
Linking GHC/Num.jsmod
Linking Control/Arrow.jsmod
Linking Control/Category.jsmod
Linking GHC/Desugar.jsmod
/home/ls/.haste/lib/GHC/Desugar.jsmod: openBinaryFile: does not exist (No such file or directory)

The file does indeed not exist.
I am node 100% sure, but I think the problem occurs when I use arrow syntax in my program.

Data.Char#toLower Calls Undefined Function u_towlower

When I run the following test program in the browser I get this error message: Uncaught ReferenceError: u_towlower is not defined

import Haste
import Data.Char

main = alert $ map toLower "HELLO"

When I call toUpper it crashes because u_towupper is missing as well.

Read works

This is not an issue for me but a surprise - read on a simple argless union type (data D = DA | DB). The readme is misleading then?

Returning values from a haskell callback?

What is the correct way to return a value from a Haskell callback? The case I'm interested in is passing a mapping function to a javascript array map function like so:

function aa(arr, fn, _) {
    return [1, 0, arr.map(function(e) { return A(fn, ...); }];
}

and then calling the javascript function from Haskell as

aa arr $ (\e -> e + 1) 

I do not seem to get any sensible values as a result. Could you tell me what am I missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.