faylang / fay

A proper subset of Haskell that compiles to JavaScript
https://github.com/faylang/fay/wiki
BSD 3-Clause "New" or "Revised" License
1.29k stars 86 forks source link

--strict automatically invokes expressions #400

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hi,

compiling the following code with --strict Test

module Test where

import FFI

alert :: String -> Fay ()
alert = ffi "alert(%1)"

loader :: Fay ()
loader = do
  alert "Hello Alert!"

generates the alert when the file is being loaded. If instead, you provide a dummy arg:

module Test where

import FFI

alert :: String -> Fay ()
alert = ffi "alert(%1)"

loader :: String -> Fay ()             -- dummy arg
loader _ = do                          -- dummy arg
  alert "Hello Alert!"

the code does not automatically alert. When looking at the stack of the unwanted alert, an anonymous function seems to be called inside the compiled code.

osa1 commented 10 years ago

I think this is same as https://github.com/faylang/fay/issues/394

ghost commented 10 years ago

you're right.